UtterAccess.com
X   Site Message
(Message will auto close in 2 seconds)

Welcome to UtterAccess! Please ( Login   or   Register )

Custom Search
 
   Reply to this topicStart new topic
> VBA Code Not Working On Only One Device., Access 2016    
 
   
Jdk412
post Feb 19 2019, 04:31 PM
Post#1



Posts: 87
Joined: 16-July 18
From: Detroit, MI


CODE
rsb.FindFirst "[SalesID]=" & Me.SalesID & " And [AllocationQuantity]=" & ALLQTY

Hello,

I am having an issue with the execution of the code above, it works fine on all of the PC's my company uses on runtime when I ty to run the code on a Microsoft surface it gives me a runtime error

the strange part is it will run the following code with no problems... which leads me to believe it has to do with the two criterias, but that is just a wild guess

Thanks

CODE
rs.FindFirst "[ShopOrder]=" & "'" & Me.Shop_Order__ & "'"

The following is the code as a whole

CODE
Private Sub BtnFrontOffice_Click()
Dim ALLQTY As Integer
Dim rs As Recordset
Dim rst As Recordset
Dim rsb As Recordset
Dim rsa As Recordset
Dim a As Integer
Dim AutoNum As Integer


    Dim cat As Object
    Set cat = CreateObject("ADOX.Catalog")
    Set cat.ActiveConnection = CurrentProject.Connection
    AutoNum = cat.Tables("Inventory").Columns("InventoryID").Properties("Seed")
    Set cat = Nothing



ALLQTY = Me.[Release Quantity] - Me.ProducedQTY

a = Me.[Release Quantity]

Set rs = CurrentDb.OpenRecordset("Inventory")
Set rst = CurrentDb.OpenRecordset("InventoryAllocation")
Set rsb = CurrentDb.OpenRecordset("InventoryAllocation")
Set rsa = CurrentDb.OpenRecordset("Inventory")


rs.FindFirst "[ShopOrder]=" & "'" & Me.Shop_Order__ & "'"
rsb.FindFirst "[SalesID]=" & Me.SalesID & " And [AllocationQuantity]=" & ALLQTY

'It never will get to this message box, unless i remove the line thats giving me errors

If MsgBox("Confirm QC Check of " & Me.QCQTY & " pieces with an inventory location of " & Me.InvLocation & "?", vbYesNo) = vbYes Then
  
    If Me.ProducedQTY + Me.QCQTY < a Then
        result = MsgBox("Is this a Partial?", vbYesNoCancel)
        
        If result = 6 Then
                Me.ProducedQTY = Me.ProducedQTY + Me.QCQTY
          
            'Change Previous allocation
            rsb.Edit
            rsb!AllocationQuantity = ALLQTY - Me.QCQTY
            rsb.Update
            
            'Create New Inventory
            rsa.AddNew
            rsa!PartNumber = Me.PartNumber
            rsa!Location = Me.InvLocation
            rsa!StartingQty = Me.QCQTY
            rsa!INVQuantity = Me.QCQTY
            rsa!Allocated = Me.QCQTY
            rsa!ShopOrder = Me.Shop_Order__
            rsa!InventoryType = "Finished Good"
            rsa.Update
            
            
            
            'Create New Allocation
            rst.AddNew
            rst!InventoryID = AutoNum
            rst!SalesID = Me.SalesID
            rst!AllocationQuantity = Me.QCQTY
            rst.Update
            
            'Reduce Previous Inventory
            rs.Edit
            rs!INVQuantity = rs!INVQuantity - Me.QCQTY
            rs.Update
            
        ElseIf result = 7 Then
            Me.ProducedQTY = Me.ProducedQTY + Me.QCQTY
  
            rs.Edit
            rs!Location = Me.InvLocation
            rs!INVQuantity = Me.ProducedQTY
            rs!InventoryType = "Finished Good"
            rs.Update
        
            Me.ShopOrderStatus = "QC Approved"
            Me.Job_Status = "Closed"
        Else
        Exit Sub
         End If
            
    Else
        Me.ProducedQTY = Me.ProducedQTY + Me.QCQTY
        rs.Edit
        rs!Location = Me.InvLocation
        rs!INVQuantity = Me.ProducedQTY
        rs!InventoryType = "Finished Good"
        rs.Update
        
        Me.ShopOrderStatus = "QC Approved"
        Me.Job_Status = "Closed"
    End If
End If


DoCmd.Close acForm, "QCApproved"
DoCmd.Requery
Go to the top of the page
 
theDBguy
post Feb 19 2019, 04:53 PM
Post#2


Access Wiki and Forums Moderator
Posts: 76,301
Joined: 19-June 07
From: SunnySandyEggo


Would it run if you use rst instead of rsb?

--------------------
Just my 2 cents... "And if I claim to be a wise man, it surely means that I don't know" - Kansas
Access Website | Access Blog | Email
Go to the top of the page
 
Jdk412
post Feb 20 2019, 09:41 AM
Post#3



Posts: 87
Joined: 16-July 18
From: Detroit, MI


well ill be [censored] it worked instantly.....

Why would that work on pcs but not a tablet?

Thank you,
Go to the top of the page
 
Jeff B.
post Feb 20 2019, 09:56 AM
Post#4


UtterAccess VIP
Posts: 10,275
Joined: 30-April 10
From: Pacific NorthWet


Perhaps totally out of left field …

If one device had (only) DAO-related objects (e.g., recordsets, etc.), and another had both ADO- and DAO-related objects, when you Dim a variable as a recordset, Access gets to (has to) decide whether that recordset is a DAO.Recordset or an ADO.Recordset …

Safer to fully Dim the variable as one or the other, and take the choice away from Access.

(also, if your db on one device doesn't have the xxx-related objects, you'll know about it right away! … and especially if you use Option Explicit at the head of the module)

--------------------
Regards

Jeff Boyce
Microsoft Access MVP (2002-2015)

Mention of hardware or software is, in no way, an endorsement thereof. The FTC of the USA made this disclaimer necessary/possible.
Go to the top of the page
 
Jdk412
post Feb 20 2019, 10:06 AM
Post#5



Posts: 87
Joined: 16-July 18
From: Detroit, MI


I see, So when I dim as a recordset it may either decide ADO or DOA... so it's just a shot in the dark whether or not access assigns the right one?

How would I go about knowing which one to use DOA or ADO?

Sorry, I'm fairly new to this whole database developing thing....
I'm just a Machinist faking it till I make it HAH!
This post has been edited by Jdk412: Feb 20 2019, 10:07 AM
Go to the top of the page
 
Jeff B.
post Feb 20 2019, 07:59 PM
Post#6


UtterAccess VIP
Posts: 10,275
Joined: 30-April 10
From: Pacific NorthWet


In the Modules (VBA code) there's a place to select/set references … the one's showing at the top of the list are checked, and you'll probably be able to tell whether you have DAO objects, ADO objects or both. Whichever is checked and listed higher is the one Access will choose … but why even risk it?!? Just Dim your database and recordset (and any other objects/variables) as one or the other. I believe I've seen that referred to as "fully qualified".

--------------------
Regards

Jeff Boyce
Microsoft Access MVP (2002-2015)

Mention of hardware or software is, in no way, an endorsement thereof. The FTC of the USA made this disclaimer necessary/possible.
Go to the top of the page
 


Custom Search


RSSSearch   Top   Lo-Fi    17th September 2019 - 09:47 AM