Slection Needed

  • Thread starter Thread starter Guest
  • Start date Start date
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
 
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
 
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
 
Back
Top