473,569 Members | 2,593 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

clearing form after insert

I'm trying to clear a form after the user clicks the Insert button so
the textboxes are empty and the checkboxes are unchecked. When I try
to put the code in the Click part of the Insert button, I get an error
telling me the Serial Number text box is empty. If I put the code in
the MouseUp part, it doesn't do anything.
please direct me to what I am doing wrong.

Feb 7 '06 #1
5 3816
Is this a form that is bound to a table or query (in the form's RecordSource
property)?

If so, you could just use this in the Click event of your command button:
If Me.Dirty Then
Me.Dirty = False
End If
If Not Me.NewRecord Then
RunCommand acCmdRecordsGot oNew
End If

If the form is unbound, you will need to loop through all the controls and
set them to Null after verifying that your submit button's write actually
worked.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Stephen D Cook" <st******@comca st.net> wrote in message
news:6o******** *************** *********@4ax.c om...
I'm trying to clear a form after the user clicks the Insert button so
the textboxes are empty and the checkboxes are unchecked. When I try
to put the code in the Click part of the Insert button, I get an error
telling me the Serial Number text box is empty. If I put the code in
the MouseUp part, it doesn't do anything.
please direct me to what I am doing wrong.

Feb 7 '06 #2

Nice try Allen. Very good!

Stephen why not posting some code so we can look better into it ?
-Pam

Feb 7 '06 #3
code is as such:

Private Sub Form_Activate()
DoCmd.GoToRecor d , , acNewRec
txtSN.SetFocus
End Sub

Private Sub cmdUpdate_Click ()
If Me![chkDead] = True Then
Me![txtDescript] = "Dead"
End If

DoCmd.GoToRecor d , , acLast
Exit Sub

There is a Serial Number textbox, a Other Problem Description text
box, a number of checkboxes for specific problems with the equipment,
and a Command Button tied to a Database, the Serial Number textbox is
bound to a SerialNumber field, and the Other Problem Description text
box is tied to the Problem field.

I put Allen's coding after the DoCmd.GoToRecor d , , acLast line of
code and it seems to work fine.

I do have one other thing I need to do, which is to pop up a message
box if there is no Serial Number entered into the Serial Number
textbox and not insert the data, as it would be invalid. I have tried
putting Msgbox coding in about everywhere I can think of with no
success. When I make the SerialNumber field in the Database required,
a message box pops up, but it is not user friendly. Any help or
suggestions with this would be helpful

On 6 Feb 2006 21:02:45 -0800, pa***********@l ibero.it wrote:

Nice try Allen. Very good!

Stephen why not posting some code so we can look better into it ?
-Pam


Feb 7 '06 #4
Use the field's Validation Rule instead of setting its Required property:

1. Open your table in design view.

2. Select the Serial Number field.

3. In the lower pane of the table design window, set:
Required: No
Validation Rule: Is Not Null
Validation Text: Don't forget the Serial Number.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Stephen D Cook" <st******@comca st.net> wrote in message
news:3j******** *************** *********@4ax.c om...

I do have one other thing I need to do, which is to pop up a message
box if there is no Serial Number entered into the Serial Number
textbox and not insert the data, as it would be invalid. I have tried
putting Msgbox coding in about everywhere I can think of with no
success. When I make the SerialNumber field in the Database required,
a message box pops up, but it is not user friendly. Any help or
suggestions with this would be helpful

Feb 7 '06 #5
Thank you very much on your help. Obviously I am new to VBA coding. I
have some experience in VB and Database Design, but VBA is a different
animal for me.
I found some code which worked in the Form_BeforeUpda te method of
If IsNull(Me.MyCom pany) Then
Cancel = True
MsgBox "You forgot 'My Company'!"
End If
End Sub
which did the trick, but your solution seems more elegant and should
cut down the processing work required.

Again, thank you very much for your generous and speedy help for a
noob to VBA.

On Tue, 7 Feb 2006 15:53:57 +0800, "Allen Browne"
<Al*********@Se eSig.Invalid> wrote:
Use the field's Validation Rule instead of setting its Required property:

1. Open your table in design view.

2. Select the Serial Number field.

3. In the lower pane of the table design window, set:
Required: No
Validation Rule: Is Not Null
Validation Text: Don't forget the Serial Number.


Feb 7 '06 #6

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

Similar topics

2
2876
by: Robin | last post by:
Ok, I have a form that on clicking of the Update button first updates the specific record in the db, then Inserts if the vMemo field is not empty. The problem that I'm having is that After updating if you hit the key (refresh) it inserts another record ... I have tried: 1. Clearing the vMemo field after the insert is done (vMemo = "") 2. ...
2
2628
by: Charles M. Fish, Sr. | last post by:
I’m so tired from banging this problem around all day, I hope I can explain it succinctly & accurately. I want to execute a function immediately following a click on <input type="RESET"... The function will insert today’s date into a <input type="TEXT"… field. It does it just fine with <form onload="insertDate();" where inside the...
2
1845
by: Savvas | last post by:
Hi everybody, I have a lot of textboxes on my form and a "Clear" button. Is there a way with a for loop or something to clear the textboxes, instead of writing textboxName.clear? Thanks a lot
7
1206
by: Paul King | last post by:
I have created a form on the web that allows us to update a table on our SQL server using the INSERT function. The way the page is constructed is that the results panel refreshes with the new data after a post has been issued. This is fine and dandy, but if we were to refresh the browser, this would duplicate another record with the same...
1
1274
by: Shahid Juma | last post by:
Hi, I have a form and when the user clicks save, it will add all the details to the database. However, when I add it to the database, how do I clear the form values? What happens is that it updates a label which I added informing that it was saved but the form is still filled in with values. Any ideas?
65
4157
by: Steven Watanabe | last post by:
I know that the standard idioms for clearing a list are: (1) mylist = (2) del mylist I guess I'm not in the "slicing frame of mind", as someone put it, but can someone explain what the difference is between these and: (3) mylist =
1
4253
by: scprosportsman | last post by:
Please help guys, i am trying to set up a database here at work and im fairly new to access in terms of writing functions and queries and stuff. I have 2 different places on my design that will require checking a check box to tell which category something will pertain to. Well after each record is entered i want the check to remain with that...
4
2168
by: high | last post by:
hi, im new to this platform, i have been creating a web page using MS Front page and i need to insert a text area to give the input and another text area to store that, <form name="myform"> <div style="left: 456; top: 803; width: 707; height: 59; position: absolute"> <table border="0" cellspacing="0" cellpadding="5"><tr>...
2
1254
by: =?Utf-8?B?UmljYXJkbyBGdXJ0YWRv?= | last post by:
for years, in every form i create in VB .Net 2005, in the FormClosing event i insert the following code: GC.Collect() GC.WaitForPendingFinalizers() but now i'm creating an application that has a very complex form and i notice that the first time that i use that form in the application the form opens fast, but after that it opens very...
0
7700
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7614
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7924
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
1
7676
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
6284
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5513
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3642
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2114
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
938
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.