Message Box Response

R

Rick

OK, I have done this in the past but now I can't remember
how I did it nor can I find anything online about
vbrespone.

Here is what I am trying to do, depending on the response
from the user, I want to either close a form or set the
focus on a field within the form. How do I write the
vbresponse code?

Here is what I'm trying but it isn't working properly:

If (IsNull([Member_Last_Name])) Then
MsgBox "Members last name has been left blank and
must be filled in. If you do not wish to enter a new
member, select Cancel.", vbOKCancel
If vbresponse Is OK Then
Me.Member_Last_Name.SetFocus

ElseIf vbresponse Is Cancel Then
DoCmd.Close
 
S

Scott McDaniel

Dim intResp as Integer

intResp = MsgBox("your message", vbYesNoCancel, "Your Title)

Select Case intResp
Case vbYes
'user selected yes ... etc etc
Case vbNo
Case vbCancel
Case Else
End Select
 
G

George Nicholson

Off the top of my head (i.e., untested):

Dim iResponse as Integer

If (IsNull([Member_Last_Name])) Then
iResponse = MsgBox ("Members last name has been left blank and
must be filled in. If you do not wish to enter a new
member, select Cancel.", vbOKCancel)

Select Case iResponse
Case vbOK
Me.Member_Last_Name.SetFocus
Case vbCancel
DoCmd.Close acForm, Me.Name
End Select
End If

If the AllowZeroLength property for this field is set to Yes, you might want
to consider changing "If IsNull([Member_Last_Name])" to "If
Len(Nz([Member_Last_Name],"")) = 0" so that it generates the prompt for
empty strings (i.e., "") as well as null values.

Hope this helps,
 
R

Rick

Worked perfect, thanks for the help. Different from what
I have done in the past but I like this way better.
Thanks again!
-----Original Message-----
Off the top of my head (i.e., untested):

Dim iResponse as Integer

If (IsNull([Member_Last_Name])) Then
iResponse = MsgBox ("Members last name has been left blank and
must be filled in. If you do not wish to enter a new
member, select Cancel.", vbOKCancel)

Select Case iResponse
Case vbOK
Me.Member_Last_Name.SetFocus
Case vbCancel
DoCmd.Close acForm, Me.Name
End Select
End If

If the AllowZeroLength property for this field is set to Yes, you might want
to consider changing "If IsNull([Member_Last_Name])" to "If
Len(Nz([Member_Last_Name],"")) = 0" so that it generates the prompt for
empty strings (i.e., "") as well as null values.

Hope this helps,

--
George Nicholson

Remove 'Junk' from return address.


OK, I have done this in the past but now I can't remember
how I did it nor can I find anything online about
vbrespone.

Here is what I am trying to do, depending on the response
from the user, I want to either close a form or set the
focus on a field within the form. How do I write the
vbresponse code?

Here is what I'm trying but it isn't working properly:

If (IsNull([Member_Last_Name])) Then
MsgBox "Members last name has been left blank and
must be filled in. If you do not wish to enter a new
member, select Cancel.", vbOKCancel
If vbresponse Is OK Then
Me.Member_Last_Name.SetFocus

ElseIf vbresponse Is Cancel Then
DoCmd.Close


.
 

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