Slection Needed

G

Guest

Hi All

on my main page to my database i have a command button that opens a second
form based on a staff member selected in the combo box. Currently if they
leave the combo box blank it automatically selects its own staff member.

what i would like it to do is if the combo bos is empty to display a msg box
saying "Please Select Staff Member".

I have attached the current code i have for the command button

Private Sub Command10_Click()
On Error GoTo Err_Command10_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "Staff Contact"

If Not IsNull(Me![Combo13]) Then
stLinkCriteria = "[Contact.StaffMember]=" & Me![Combo13]
Else
stLinkCriteria = ""
End If

DoCmd.OpenForm stDocName, , , stLinkCriteria
Dim strForm As String
strForm = "Main"
If CurrentProject.AllForms(strForm).IsLoaded Then
DoCmd.Close acForm, strForm
End If

Exit_Command10_Click:
Exit Sub

Err_Command10_Click:
MsgBox Err.Description
Resume Exit_Command10_Click

End Sub

Thanks in advance
 
D

Douglas J. Steele

If Not IsNull(Me![Combo13]) Then
stLinkCriteria = "[Contact.StaffMember]=" & Me![Combo13]
DoCmd.OpenForm stDocName, , , stLinkCriteria
Dim strForm As String
strForm = "Main"
If CurrentProject.AllForms(strForm).IsLoaded Then
DoCmd.Close acForm, strForm
End If
Else
MsgBox "Please Select Staff Member"
End If
 
G

Guest

Thanks For the fast reply. Works like a charm.

Douglas J. Steele said:
If Not IsNull(Me![Combo13]) Then
stLinkCriteria = "[Contact.StaffMember]=" & Me![Combo13]
DoCmd.OpenForm stDocName, , , stLinkCriteria
Dim strForm As String
strForm = "Main"
If CurrentProject.AllForms(strForm).IsLoaded Then
DoCmd.Close acForm, strForm
End If
Else
MsgBox "Please Select Staff Member"
End If

--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


Andrew C said:
Hi All

on my main page to my database i have a command button that opens a second
form based on a staff member selected in the combo box. Currently if they
leave the combo box blank it automatically selects its own staff member.

what i would like it to do is if the combo bos is empty to display a msg
box
saying "Please Select Staff Member".

I have attached the current code i have for the command button

Private Sub Command10_Click()
On Error GoTo Err_Command10_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "Staff Contact"

If Not IsNull(Me![Combo13]) Then
stLinkCriteria = "[Contact.StaffMember]=" & Me![Combo13]
Else
stLinkCriteria = ""
End If

DoCmd.OpenForm stDocName, , , stLinkCriteria
Dim strForm As String
strForm = "Main"
If CurrentProject.AllForms(strForm).IsLoaded Then
DoCmd.Close acForm, strForm
End If

Exit_Command10_Click:
Exit Sub

Err_Command10_Click:
MsgBox Err.Description
Resume Exit_Command10_Click

End Sub

Thanks in advance
 

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