473,405 Members | 2,210 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

Clear Control

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
Nov 13 '05 #1
5 2098
how about
ctl.Setfocus
ct.Text=""

or somesuch?

Wow that code is hard to read... and Option Explicit is your FRIEND.

Nov 13 '05 #2
Mike wrote:
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


Me.biddernum.Undo

Not sure it's a good idea though. The user might well want to see the entry
that your program is telling him is incorrect before he corrects it. That would
be more standard behavior.

--
I don't check the Email account attached
to this message. Send instead to...
RBrandt at Hunter dot com
Nov 13 '05 #3
pi********@hotmail.com wrote in news:1112068311.538533.167040
@z14g2000cwz.googlegroups.com:
how about
ctl.Setfocus
ct.Text=""

or somesuch?

Wow that code is hard to read... and Option Explicit is your FRIEND.


I have no formal VB training. Everything is self taught. I have tried the
option explicit before and it has caused me problems as I learned to code
back inteh days of actual basic.

Anyway I tried both you suggestion and Me.ctl,Undo but neither one worked.
But I think I will leave it as is that way the user can see the incorrect
entry so they know what the problem was,

Thanks for the responce.

Mike
Nov 13 '05 #4
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
Nov 13 '05 #5
strvariant <no.email.com> wrote in news:Xns9628D8AC71E52noemailcom@
216.196.97.136:
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


Thanks. I got it!
Mike
Nov 13 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: André Minhorst | last post by:
Hi, some time ago Stephen Lebans advised me to 'clear' the RTF2-Control to prevent some problems with it. Unfortunately I did not find a way to clear this control before inserting the RTFText...
3
by: JD | last post by:
Is it possible to have a clear backstyle for a lable control? I want to write some text on a lable and I want the background of the label to match the color of the control I am placing the label...
2
by: Mike | last post by:
Ok I'm having a problem with a listview. I have a listview on a WinForm called ProgramInformationFrm. I call this from from 2 other forms. One is ProgramSearch Frm, the other is OpenNCFrm. The...
2
by: nmakhan | last post by:
I have a validation summary that I use soley for my Required Field Validators. That works fine if I do things that way up to a point, if by chance the validation summary says "Date field...
0
by: =?Utf-8?B?TWljaGFlbA==?= | last post by:
Hello, I want to control my WebParts programmatically. I have it set up so I can load my WebParts from code. The user can move them around. But I want to clear what they have done the next time...
6
by: RP | last post by:
I want to clear all the Text Boxes on the Form. Is there any short method to avoid clearing them one by one.
5
by: karsagarwal | last post by:
I have a bounded form and after I click the button to update/save. THe fields are still there. Is there a way to clear off the fields in the bounded form. Thanks, SA Here's the code that I...
32
by: =?Utf-8?B?U2l2?= | last post by:
I have a form that I programmatically generate some check boxes and labels on. Later on when I want to draw the form with different data I want to clear the previously created items and then put...
5
aas4mis
by: aas4mis | last post by:
I haven't had much luck with specific controls, their properties and loops in the past. I thought I would share this tidbit of code, feel free to modify/modularize in any way to suit your needs. This...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.