Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

msgbox 1

Status
Not open for further replies.

katiekat

Technical User
Jun 6, 2000
300
US
Hey there! Here's my question:

I want to put a message box in the onchange event in a form. So if someone changes this field, they have to confirm before the reccords are saved. I'm having a hell of a time figuring out the syntax for the bleeping things. I just need a simple yes/no/cancel box, and the help files are confusing me more than they are helping. The basic syntax would be a great help. :) Thank you!

Kate Holy tek-tips batman!:-0
 
If MsgBox("Are you sure you want to change this textbox?", vbYesNo) = vbYes Then
'Do something here
Else
'Do something else here
End If ljprodev@yahoo.com
ProDev
MS Access Applications
 
The way I would do it is create a variable in the form General Declarations section like;

Public varMyText as variant

in the form's OnCurrent event

varMyText = recset.Field(Myfield)

in the field's OnChange event place this:
Dim msg as string, Style as integer, Response as integer

if me.txtMyfield <> varMyText then
Msg = &quot;The value for this field has changed. Do you wish to save changes?&quot;

Style = vbYesNoCancel
Response = Msgbox(Msg, Style, &quot;Please Confirm&quot;)

select case response
case vbyes

case vbno
me.txtfield = varMyText
end select
end if


You could also put this last bit of code in the the Click event of a Save command button.

Hope that helps.

Bob
 
Thanks guys! Holy tek-tips batman!:-0
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top