msgbox appearing when control is about to be edited

G

Guest

in my a2k db my "Registration" form is bound to a table of the same name.
each has "Patient Number" in it, and this control is the table's PK. moreover
i'm allowing changes to "Registration" form and it is the driving force
behind every other table in the db. w/o an entry in "Patient Number",
combobox l/u controls in the other forms would not be able to enter a
"Patient Number" in the allocated control. w/ that said, i have enabled
cascading updates/deletes throughout the db. what i'm writing to learn how to
activate is the ability for a msgbox to appear when the user goes to edit the
"Patient Number" field inasmuch as i don't believe there's a system generated
msg that tells the user what the far reaching consequences will be.

thanks in advance, i bet someone'd gone through this b4.

-ted
 
G

Guest

You could use the BeforeUpdate event of the Patient Number textbox to prompt
the user with a MsgBox, that way you can spell it out in plain english for
them. The user could then based on the options you give, accept the change,
or cancel it.

HTH.
 
G

Guest

thnaks paul b. i will give this a try when i return to the office tomorrow. i
thought it might've been conditioned upon the so called dirty event or ditry
property, but if i see what you're saying correctly, whenever the "Patient
Number" field is non null and the user makes an attempt to change it, the
BeforeUpdate event will conditionally actuate the MsgBox function and query
him for his answer to the prompts.

-te
 
G

Guest

hey paul b:

can you take a look at this code i put together this morning and tell me why
i'm getting an error 424 "object required" error?


Private Sub Patient_Number_BeforeUpdate(Cancel As Integer)
If Me.Dirty = True And Me.Patient_Number.OldValue Is Not Null Then
If vbCancel = MsgBox("You are about to change the ID Number of this Patient
from " & Me.Patient_Number.OldValue & " to " _
& Me.Patient_Number.Value & "!! This change will be have the effect of
occuring everywhere throughout this database", _
vbCritical + vbOKCancel + vbDefaultButton2, "SUPER HYPER ULTRA CRITICAL") Then
Me.Patient_Number.Value = Me.Patient_Number.OldValue
End If
End If
End Sub
 
G

Guest

Try this Ted....

Private Sub Patient_Number_BeforeUpdate(Cancel As Integer)

Dim lngRetval as Long

If Me.Dirty = True And Me.Patient_Number.OldValue Is Not Null Then
lngRetval = MsgBox("You are about to change the ID Number of this Patient
from " & Me.Patient_Number.OldValue & " to " &
Me.Patient_Number.Value
& "!! This change will be have the effect of occuring everywhere
throughout
this database", vbCritical + vbOKCancel + vbDefaultButton2, "SUPER
HYPER
ULTRA CRITICAL")

Select Case lngRetval
Case vbOK
Me.Patient_Number.Value = Me.Patient_Number.OldValue
Case vbCancel
Exit Sub 'Or Whatever you need to do here.
End If
End Sub
 
G

Guest

hey paul b.,

thanks for the bandwidth.....here's what i'm using and i think it's working
Private Sub Patient_Number_BeforeUpdate(Cancel As Integer)
If Me.Dirty = True And Not IsNull(Me.Patient_Number.OldValue) Then
If vbCancel = MsgBox("You are about to change the ID Number of this Patient
from " & Me.Patient_Number.OldValue & " to " _
& Me.Patient_Number.Value & "!! This change will be have the effect of
replacing " & Me.Patient_Number.OldValue & " throughout this database!!", _
vbCritical + vbOKCancel + vbDefaultButton2, "SUPER HYPER ULTRA CRITICAL") Then
Cancel = True
Me.Patient_Number.Undo
End If
End If
End Sub

-ted
 

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