Results 1 to 2 of 2
Thread: If No Data , Then? (2000)
2003-06-13, 14:42 #1
- Join Date
- Feb 2001
- Louisville, Kentucky, USA
- Thanked 0 Times in 0 Posts
If No Data , Then? (2000)
I would like to let the user know that they either input an invalid ID to open a form. I currently have the following code to open the form (it works fine)..I want to enhance it by adding a peice of code informing them that, if they input an invalid ID or perhaps they mistyped an ID, that a msg comes up and tells them...therefore the the original msgbox returns and offers them the opportunity to retry....and the form still doesn't open.....I hope I was clear and someone can offer some insight....I have a peice of code I've been working on...but I continue to get a "mismatch" error...so I give up and will call on the MASTERS!!!! LOL
Here is the code that works fine:
Dim strInput As String, strMsg As String, strHW As String
Dim stDocName As String, stLinkCriteria As String
DoCmd.Close acForm, "frmDMEUsage"
DoCmd.Close acForm, "Switchboard"
DoCmd.Close acForm, "frmMDFollowUp"
strMsg = "Insert Maid Number"
strHW = InputBox(strMsg)
If strHW <> "" Then
Me.txtMaidNum = strHW
stDocName = "frmMDFollowUp"
Me![txtMaidNum] & "'"
stLinkCriteria = "[RecipientMaidNum]=" & "'" & Me![txtMaidNum] & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria
DoCmd.Close acForm, "frmMaidNumLU"
DoCmd.OpenForm "Switchboard", acNormal, "", "", , acNormal
Here is the code I'm struggling with:
Dim strMsg As String, strTitle As String
Dim intStyle As Integer
If IsNull(Me.RecipientMaidNum) = "" Then
strMsg = "That ID isn't valid"
strTitle = "Please try again"
intStyle = vbOKOnly
MsgBox strMsg, intStyle, strTitle
Cancel = True
Thanks All,Roberta Price <img src=/S/cheers.gif border=0 alt=cheers width=30 height=16>
2003-06-13, 15:23 #2
- Join Date
- Mar 2002
- Thanked 28 Times in 28 Posts
Re: If No Data , Then? (2000)
I would consider another approach: instead of letting the user type an ID and then being hit around the ears with a message that the value is incorrect, let the user select the ID from a list of valid ID's. An unbound combo box is ideal for that. The row source of the combo box can be a query that selects the unique ID's:
SELECT DISTINCT RecipientMaidNum FROM tblMaids
(substitute the actual name of the table). Set the LimitToList property of the combo box to Yes, so that the user can't enter an incorrect ID.