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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help with code???

Status
Not open for further replies.

Ryon

Technical User
Nov 1, 2002
64
US
could someone help me with this statement, I am new to this and learning. I keep getting a " function call on left hand side of statement must return avariant or an object" Thanks ahead of time. Again!!!


Private Sub Form_BeforeUpdate(Cancel As Integer)
If Not IsNull(CALLNUM.Value) And IsNull(KEY.Value) Then
DoCmd.CancelEvent
MsgBox("You Must Assign A Client To This Ticket!", vbCritical, "CLIENT NAME", , , vbOKOnly) = vbOK
 
Hi!

Try it like this:

Private Sub Form_BeforeUpdate(Cancel As Integer)
If Not IsNull(CALLNUM.Value) And IsNull(KEY.Value) Then
MsgBox("You Must Assign A Client To This Ticket!", vbCritical + vbOkOnly, "CLIENT NAME")
Cancel = -1
End If

hth
Jeff Bridgham
bridgham@purdue.edu
 
The error is the =vbOK, it is not needed.

MsgBox("You Must Assign A Client To This Ticket!", vbCritical, "CLIENT NAME", , , vbOKOnly) = vbOK

Try this:

MsgBox "You Must Assign A Client To This Ticket!", vbCritical + vbOKOnly, "CLIENT NAME"

I keep learning something new everyday, I have been at this for a long time!

Good luck!
Anthony J. DeSalvo
President - ScottTech Software
"Integrating Technology with Business"
 
A note which took me quite a while to realize when I was beginning reading the books and working with the programming, If you're not expecting a return value in a function call, or don't care about the return value, do not use parenthesis when calling the function.

If you are saving or testing the return value then you must use the parenthesis.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top