473,411 Members | 1,880 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,411 software developers and data experts.

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 3798
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 acCmdRecordsGotoNew
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******@comcast.net> wrote in message
news:6o********************************@4ax.com...
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.GoToRecord , , acNewRec
txtSN.SetFocus
End Sub

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

DoCmd.GoToRecord , , 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.GoToRecord , , 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***********@libero.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******@comcast.net> wrote in message
news:3j********************************@4ax.com...

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_BeforeUpdate method of
If IsNull(Me.MyCompany) 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*********@SeeSig.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
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...
2
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"... ...
2
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
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...
1
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...
65
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...
1
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...
4
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...
2
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...
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: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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,...
0
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...

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.