473,856 Members | 1,710 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 3828
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
2895
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. Setting the value on the form for this field to "" Neither of these are working. It's not...
2
2653
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 ‘insertDate’ fn, I have document.form.dateField.value = dateString. The closest I’ve been able to do...
2
1874
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
1214
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 details. I would there like to either:
1
1289
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
4267
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
4274
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 record and auto clear when going to the next record so i can input something else if i have a...
4
2184
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> <td><textarea name="inputtext" rows="1" cols="20"></textarea></td> <input type="radio" name="placement"...
2
1260
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 slowly. I can only think that the problem has to do with cleaning the variables/objects. Does this...
0
10696
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10782
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 most users, this new feature is actually very convenient. If you want to control the update process,...
0
10384
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9531
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 launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7932
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 instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5761
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5958
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4575
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
2
4174
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.