Mike <me@you.net> wrote in
news:v9*****************@newssvr31.news.prodigy.co m:
I have a form that has a control on it. When data is entered into the
control I verify that is good with the follwoing code:
==> Begin Code <==
Dim ct, curbidnum
curbidnum = Me.biddernum
ct = DCount("[lastname]", "tblbiddersignin",
"[biddernum] = '"
& Me.biddernum & "'")
If ct = 0 Or IsNull(ct) Or ct = "" Then
MsgBox "Please check the bidder number: " &
curbidnum & Chr
$(13) & Chr$(13) & "It is not signed in for todays
auction.", vbOKOnly, "Bidder Number Entry Error"
Cancel = True
Exit Sub
End If
==> End Code <==
This works except that when it returns to the control after a bad data
entry it does not clear the current data in the control. I want the
code to return to the control but also clear the control. I cant see
to figure out how to accomplish this. Does anyone have any ideas?
Thanks in advance!
Private email is mbcharney AT sbcglobal dot net
Thanks Mike Charney
Hi Mike,
I'll have a try ---
==> Begin Code <==
Dim ct, curbidnum
'***Evaluate the control [Me.biddernum]'s value first
'***If it's Null, an empty string or equals 0 then
'***notify the user and display the value
If IsNull(Me.biddernum) or Me.biddernum = "" or Me.biddernum = 0 then
curbidnum = Me.biddernum
Msgbox "Please check the bidder number: " & curbidnum _
& chr$(13) _
& chr$(13) _
& "It is not signed in for todays auction.",vbOkOnly, _
"Bidder Number Entry Error"
'***--------------------------------------------------------
'***If Me.biddernum is the control to clear, try this:
Me.biddernum.SetFocus
Me.biddernum = ""
'***If ct is the control to clear, try this:
ct = ""
'***--------------------------------------------------------
Cancel = True
Else
'***Otherwise, set curbidnum equal to the control's value
'***and set ct equal to the DCount() expression
curbidnum = Me.biddernum
ct = DCount("[Lastname]", "tblbidderssignin", "[biddernum] = '" _
& curbidnum & "'")
End If
End Sub
==> End Code <==
No guarantees but it may get you where you need to go. Hope it helps!
strvariant