Quote:
quote:Originally posted by bph
In other words can a messagebox contain a value from a textbox on a form? And how?
|
Yes, what you can do if you want to verify each and every field (I hope there are not many of them!

) is something like this:
Code:
Dim ctlMyControl as Control
Dim varAnswer as Variant
'Cycle through all the controls in the form.
For Each ctlMyControl in Me
'Only work with textboxes, not other controls.
If ctlMyControl.ControlType = acTextBox Then
'Point to the control and highlight it.
ctlMyControl.SetFocus
ctlMyControl.BackColor = vbYellow
'Ask the question. Control's name is on top of dialog box.
varAnswer = MsgBox("Are you sure the entry and its spelling are correct?", _
vbQuestion + vbYesNo, ctlMyControl.Name)
'There is an error. Exit and leave the cursor there.
If varAnswer = vbNo Then
ctlMyControl.BackColor = vbWhite
Exit Sub
End If
End If
Next
ctlMyControl.BackColor = vbWhite
If you answer "Yes" to the question for all textboxes, your cursor will end up sitting at the last one.
I haven't tested this so be wary of syntax errors!
Greg Serrano
Michigan Dept. of Environmental Quality, Air Quality Division