Command button code not opening my form


T

Tony Williams

I have a form, frmMain that has a subform, Subform1. On the main form is a
command button that opens a dialog box from which the user can select a
record from a dropdown list. The dialog form has a command button that when
clicked SHOULD change the record on the subform to the record with the
reference number they have selected. But it doesn't. Here is my code:

Private Sub Command2_Click()
On Error GoTo Command2_Click_Err
Dim stLinkCriteria As String
stLinkCriteria = "[VFU Code]=" & "'" & Me![VFU Code] & "'"

If IsNull(DLookup("[VFU Code]", "Offence", stLinkCriteria)) Then
MsgBox "This is not a current VFU Code.", _
vbInformation, "No Matching Record"
Else
DoCmd.OpenForm frmMain.SubForm1, , , "[VFU Code]=" & "'" & Me![VFU
Code] & "'"

End If



Command2_Click_Exit:
Exit Sub

Command2_Click_Err:
'MsgBox Error$
Response = acDataErrContinue
Resume Command2_Click_Exit

End Sub

Anyone tell me where I'm going wrong
 
Ad

Advertisements

T

Tony Williams

Just a note the subform is unbound as it shows different subforms depending
upon a menu choice.
Thanks
Tony
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top