jamierbooth
Registered User.
- Local time
- Today, 12:24
- Joined
- Oct 23, 2013
- Messages
- 36
Hello world...
I have a form I use to search for clients when I hit a command button, using surname etc. I'd like a yes no button to pop up rather than the clunky ok button route I currently have. I'm a beginner with VBA and most this I've gleaned from internet.
If there are matching results, everything is fine. If there are no matching results, I've managed to get my desired messagebox come up by using the code below in the onload event of the resulting search results form, however the yes no buttons do nothing and the results form loads blank as though no records were found.
I'd like Yes to send users to the client input form, and No to return them to the search form. What's wrong here??
Private Sub Form_Open(Cancel As Integer)
If Me.Recordset.RecordCount = 0 Then
MsgBox "Do you want to add a new Client?", vbQuestion + vbYesNo, "No clients found"
Select Case intanswer
Case vbYes
DoCmd.OpenForm "FrmNewClient"
DoCmd.OpenForm stDocName, , , acFormAdd
DoCmd.Close acForm, Me.Name
Case vbNo
DoCmd.OpenForm "SearchF"
End Select
End If
End Sub
Any help would be great!
Jamie.
I have a form I use to search for clients when I hit a command button, using surname etc. I'd like a yes no button to pop up rather than the clunky ok button route I currently have. I'm a beginner with VBA and most this I've gleaned from internet.
If there are matching results, everything is fine. If there are no matching results, I've managed to get my desired messagebox come up by using the code below in the onload event of the resulting search results form, however the yes no buttons do nothing and the results form loads blank as though no records were found.
I'd like Yes to send users to the client input form, and No to return them to the search form. What's wrong here??
Private Sub Form_Open(Cancel As Integer)
If Me.Recordset.RecordCount = 0 Then
MsgBox "Do you want to add a new Client?", vbQuestion + vbYesNo, "No clients found"
Select Case intanswer
Case vbYes
DoCmd.OpenForm "FrmNewClient"
DoCmd.OpenForm stDocName, , , acFormAdd
DoCmd.Close acForm, Me.Name
Case vbNo
DoCmd.OpenForm "SearchF"
End Select
End If
End Sub
Any help would be great!
Jamie.