Monobi
09-22-2009, 03:20 AM
Hi all,
For the past week or so I have been creating an Access database a small amount each day. For the past two days I've been debugging the code which I have written and am down to the last bug.
I have a main form displaying the Purchase Order's date, ID, corresponding supplier and a subform displaying the items on the order.
Private Sub txtPO_BeforeUpdate(Cancel As Integer)
Dim Message
'Check if the change exists
If Not IsNull(DLookup("[txtPO]", "[Purchase Orders]", _
" [PO Number] = " & [txtPO].Value)) Then
DoCmd.GoToRecord , , acGoTo, [txtPO].Value 'On change, set that number to display
Else
'If not, inform user and reset box
Message = MsgBox("Specified Purchase Order does not exist.")
Cancel = True
End If
End Sub
txtPO is a text box set to the autonumber primary key of the first table (the second being the document items.)
I get a runtime error 2105 - "Cannot go to specified record." When debugging, the record exists, the syntax follows orders... I'm wondering if there is something unmentioned going wrong?
Thanks for any help,
Ben
For the past week or so I have been creating an Access database a small amount each day. For the past two days I've been debugging the code which I have written and am down to the last bug.
I have a main form displaying the Purchase Order's date, ID, corresponding supplier and a subform displaying the items on the order.
Private Sub txtPO_BeforeUpdate(Cancel As Integer)
Dim Message
'Check if the change exists
If Not IsNull(DLookup("[txtPO]", "[Purchase Orders]", _
" [PO Number] = " & [txtPO].Value)) Then
DoCmd.GoToRecord , , acGoTo, [txtPO].Value 'On change, set that number to display
Else
'If not, inform user and reset box
Message = MsgBox("Specified Purchase Order does not exist.")
Cancel = True
End If
End Sub
txtPO is a text box set to the autonumber primary key of the first table (the second being the document items.)
I get a runtime error 2105 - "Cannot go to specified record." When debugging, the record exists, the syntax follows orders... I'm wondering if there is something unmentioned going wrong?
Thanks for any help,
Ben