Which Event?

  • Thread starter Thread starter bw
  • Start date Start date
B

bw

I have a form "Profile" which has a command button that sends user to
another form "Modules" (the command button is the only way for the user to
get to the form "Modules").

I have an After Update event procedure that includes the following:
X = DLookup("BankName", "qryLookup", "BankName = '" & [BankName] &
"'")
If IsNull(X) Then...show and error message.

Problem:
Whenever the user clicks on the command button, I want to execute the code
for the After Update event (even though the record may not have been
updated), and If IsNull(X) then show the error message, but DON'T go to the
form "Modules".

Questions:
Which Event do I use for this? Do I simply move the After Update event
procedure code to this new event?
How do I stop the command button from going to the "Modules" form?

Thanks,
Bernie
 
Not sure what you're doing here, but...
Just copy the AfterUpdate code and paste it into the OnClick event for your
button. Then delete the OpenForm code you wrote from the button Click
event.

The AfterUpdate code can be done in one statement...

Private Sub cmdYourButtonName_Click()
IIF IsNull(DLookup("BankName", "qryLookup", "BankName = '" & [BankName]
& "'") Then
'msg box... and show error message.
End If
End Sub

hth
Al Camp

bw said:
I have a form "Profile" which has a command button that sends user to
another form "Modules" (the command button is the only way for the user to
get to the form "Modules").

I have an After Update event procedure that includes the following:
X = DLookup("BankName", "qryLookup", "BankName = '" & [BankName]
&
"'")
If IsNull(X) Then...show and error message.

Problem:
Whenever the user clicks on the command button, I want to execute the
code
for the After Update event (even though the record may not have been
updated), and If IsNull(X) then show the error message, but DON'T go to
the
form "Modules".

Questions:
Which Event do I use for this? Do I simply move the After Update event
procedure code to this new event?
How do I stop the command button from going to the "Modules" form?

Thanks,
Bernie
 
AlCamp,

I haven't tried what you suggested, but I'm sure it will work. What I
forgot in this process, is that I have to avoid closing the first form until
I'm sure I want to go to the second form. I THINK I know what I'm doing
now.

Thanks for your help,
Bernie

AlCamp said:
Not sure what you're doing here, but...
Just copy the AfterUpdate code and paste it into the OnClick event for your
button. Then delete the OpenForm code you wrote from the button Click
event.

The AfterUpdate code can be done in one statement...

Private Sub cmdYourButtonName_Click()
IIF IsNull(DLookup("BankName", "qryLookup", "BankName = '" & [BankName]
& "'") Then
'msg box... and show error message.
End If
End Sub

hth
Al Camp

bw said:
I have a form "Profile" which has a command button that sends user to
another form "Modules" (the command button is the only way for the user to
get to the form "Modules").

I have an After Update event procedure that includes the following:
X = DLookup("BankName", "qryLookup", "BankName = '" & [BankName]
&
"'")
If IsNull(X) Then...show and error message.

Problem:
Whenever the user clicks on the command button, I want to execute the
code
for the After Update event (even though the record may not have been
updated), and If IsNull(X) then show the error message, but DON'T go to
the
form "Modules".

Questions:
Which Event do I use for this? Do I simply move the After Update event
procedure code to this new event?
How do I stop the command button from going to the "Modules" form?

Thanks,
Bernie
 
Back
Top