Msgbox Form Reload

S

Scarlet

Hello,

I am attempting to put in place a message box that loads when conditions are
not met between two fields. If the conditions do not match I would like the
current form the user is on to refresh, upon clicking a button from a msgbox.
Thus far my code is as follows...please be patient with me as I am relatively
new at this. Thanks!!

IF cboResort <> (Ltrim([txtDeed] , 2) ' here i am saying that the 2
characters in cboResort must match the first two characters in the string
txtDeed

THEN Msgbox("Please Try Again", 'not sure of the code relevant to the
button/creating the button itself in access

Else End
End If

Thanks!!!
 
J

Jason

If I understand - you don't want to give the user an option to refresh or not?

If this is the case:

msgbox ("Please try again.", vbOKonly)
me.refresh

If you want them to have the option not to refresh:

Dim response

response = (msgbox("Please try agagin", vbOKCancel))
If response = vbOK Then
Me.Refresh
End If
 
K

Klatuu

The Ltrim function is not what you want for this exercise. You want the Left
function:
IF Me.cboResort <> Left(Me.[txtDeed] , 2) Then
MsgBox "Please Try Again", vbExclamation + vbOKOnly
Else
'Do something Here
End If
.......
 
S

Scarlet

Klatuu and Jason,

A sincere thanks, everything works just great!!
The Ltrim function is not what you want for this exercise. You want the Left
function:
IF Me.cboResort <> Left(Me.[txtDeed] , 2) Then
MsgBox "Please Try Again", vbExclamation + vbOKOnly
Else
'Do something Here
End If
......
[quoted text clipped - 15 lines]
Thanks!!!
 
S

Scarlet

Now i would like to have a button where if the conditions of the error box
are not met it does not let you proceed to the next form load....

here is the code thus far...

Private Sub txtDeed_AfterUpdate()
Dim stResort As String
Dim stFirstofdeed As String
Dim iResponse As Integer


If gstRCode <> Left(txtDeed.Text, 2) Then
iResponse = MsgBox("Resort Code & Deed Inventory Code Must Match", vbOKOnly +
vbCritical, "Deed & Resort Do Not Match")


End If
End Sub

Thanks again!!

Klatuu and Jason,

A sincere thanks, everything works just great!!
The Ltrim function is not what you want for this exercise. You want the Left
function:
[quoted text clipped - 10 lines]
 
Top