I’m desperately trying to get this to work…..
My application lets the user set up a work order and everything’s working fine except for an intermittent problem that happens when they are requesting that a new machine or tool is added to a drop-down list of machines/tools. What’s supposed to happen is, after the machine/tool is chosen, the work order number is assigned by taking the year, then tacking on the autonumber of the work order entry. The machine/tool is added to the appropriate table, then…
Private Sub Tools_AfterUpdate()
Dim myresults As String, myresults1 As String, msg As String, msg1 As String, msg2 As String
………here’s where it’s adding the new tool…….now it’s trying to do the rest
Select Case msg2
Case vbYes
DoCmd.SetWarnings False
‘this updates the tool list
DoCmd.OpenQuery “q_newWorkTool”
Tools.Requery
DoCmd.RunCommand acCmdSaveRecord
DoCmd.RunCommand acCmdSaveRecord
…..here’s where it’s supposed to calculate the work order id, then display it on the screen. (workID)
DoCmd.OpenQuery “Q_UpdWorkOrderID”
Me.WorkID.Visible = False
Me.WorkID.Requery
Me.WorkID.Visible = True
DoCmd.RunCommand acCmdSaveRecord
DoCmd.SetWarnings True
Case vbNo
msg1 = “Please try again”
msg2 = msgbox(msg1, vbDefaultButton1, “Status”)
Let Me.Machine = ” ”
End Select
….if an existing machine/tool…….
Else
DoCmd.RunCommand acCmdSaveRecord
DoCmd.SetWarnings False
DoCmd.OpenQuery “Q_UpdWorkOrderID”
Me.WorkID.Visible = False
Me.WorkID.Requery
Me.WorkID.Visible = True
DoCmd.SetWarnings True
End If
End Sub
What happens, sometimes (and there is no reason why it should), is that the work order number doesn’t get updatedon a new machine/tool, and stays as 0. To try to counter this problem (we can’t have 15 work orders with 0 on them), when the user exits the screen, the code checks to make sure that the work order number isn’t 0:
If Me.WorkID = 0 Then
DoCmd.OpenQuery “Q_UpdWorkOrderIDtest”
Me.WorkID.Requery
Else
End If
Now, you’d think everything would work – well, it doesn’t. Any suggestions?