Hi!
I'm loosing my nerves!!! I normaly use Access 2003 but for the moment Access 2007 Trial and i'm not familiar with the VBA language nor SQL.
I'm making a form where i add data into text/list boxes and then press a button to run an append query to have it inserted into a table. Simple, yes but how can i make the data to clear from my form on for example mouse up (when I have clicked the button). I know one can use the setvalue command by using macros, but the pain in specifing every single object and having "millions" of macros isn't really an attractive option. So couldn't it be done using the expression builder??
Tank you
23 19096
Hi!
I'm loosing my nerves!!! I normaly use Access 2003 but for the moment Access 2007 Trial and i'm not familiar with the VBA language nor SQL.
I'm making a form where i add data into text/list boxes and then press a button to run an append query to have it inserted into a table. Simple, yes but how can i make the data to clear from my form on for example mouse up (when I have clicked the button). I know one can use the setvalue command by using macros, but the pain in specifing every single object and having "millions" of macros isn't really an attractive option. So couldn't it be done using the expression builder??
Tank you
In VBA the following command will clear all unbound controls
Mary
Thank you for the fast response,
I try to add the command but when I click my button the screen flickers slightly but nothing happens, my textbox still has the text i wrote???
Any advice?
Thanks
Try:
me.RecordSource=me.RecordSource
Looks funny, but should work
Nic;o)
Still completly lost.
I've made a new form thats not bound to enything added a textbox (unbound) and a button. I set the OnClick to both Me.Refresh and me.RecordSource=me.RecordSource.
------------------------------------------------------------------
Private Sub Command2_Click()
Me.Refresh
End Sub
------------------------------------------------------------------
Private Sub Command2_Click()
Me.RecordSource=Me.RecordSource
End Sub
------------------------------------------------------------------
So what am i doing wrong???
For emptying a field on an unbound form use:
Me.Fieldname = ""
Me.refresh
Nic;o)
yiiiihaaa!!!
It worked thanks everybody, 2 days of misserable pain is over.
If someone still has a command for clearing the whole record/form please post but with this I will already come a long way.
Thanks again
NeoPa 32,534
Expert Mod 16PB
This routine (Public in a non-object module) should do it for you.
There is flexibility to treat different object types differently with a small change to the Select Case statement. - 'ClearUnbound empties all controls on an unbound form.
-
Public Sub ClearUnbound(frmMe As Form)
-
Dim varCtrl As Variant
-
-
For Each varCtrl In frmMe.Controls
-
With varCtrl
-
Select Case .ControlType
-
Case acCheckBox, acComboBox, acListBox, acTextBox
-
.Value = Null
-
End Select
-
End With
-
Next varCtrl
-
End Sub
Thanks
But I can't get it to work it starts whining about the privet sub - Private Sub Command45_Click()
-
'ClearUnbound empties all controls on an unbound form.
-
Public Sub ClearUnbound(frmMe As Form)
-
Dim varCtrl As Variant
-
-
For Each varCtrl In frmMe.Controls
-
With varCtrl
-
Select Case .ControlType
-
Case acCheckBox, acComboBox, acListBox, acTextBox
-
.Value = Null
-
End Select
-
End With
-
Next varCtrl
-
End Sub
-
End Sub
Please remember that for the moment being, Iknow nothing about VBA
NeoPa 32,534
Expert Mod 16PB
That's because you're not doing it quite right (All right - it's all wrong).
That's not a problem though, we all have to start somewhere.
Follow these instructions : - Open the database in Access.
- Switch to the VBA Window (Alt-F11).
- Insert / Module.
- Copy the ClearUnbound procedure in.
- Switch back to Access (Alt-F11 again).
- Open your form in Design Mode.
- Right-click on your Command45 control and select Build Event...
- Type in the code below :
- Call ClearUnbound(frmMe:=Me)
- Debug / Compile ... (Project Name).
- Save.
Thanks allot
I used to be a computer administrator at a small firm but never had the need of programming, so I just let it be. Then one day someone came in and asked me if I knew anything about the "For Dummies" series of books (which I didn't), but I answerd "Oh them, they are for morrons".
Guess what! I just ordered 400 pages of "Programming Access 2007 For Dummies"
What do we learn from this? Just keep your mouth shut or your a morron : )
Anyways, Thanks it worked like a charm, and you have lightened a few lights for me, though have quite a few more to go and I'll be there.
NeoPa 32,534
Expert Mod 16PB
Well, we'll be happy to help light you on your way :)
Oh, and by the way, do you think we all haven't been there or thereabouts ourselves once?
Yes I know everyone has been here, it was just the preassure valve that bursted.
You know the fealing? You think you know what you are doing but it just won't work, copy/pasting, reading helpfiles etc for hours.
This is called anger management : )
Well, we'll be happy to help light you on your way :)
Oh, and by the way, do you think we all haven't been there or thereabouts ourselves once?
Speak for yourself. I always knew everything. I was borned that way :D
NeoPa 32,534
Expert Mod 16PB
Yes I know everyone has been here, it was just the preassure valve that bursted.
You know the fealing? You think you know what you are doing but it just won't work, copy/pasting, reading helpfiles etc for hours.
This is called anger management : )
I suppose that's one way of doing it - if you can't find anyone nearby to punch I suppose :D
NeoPa 32,534
Expert Mod 16PB
Speak for yourself. I always knew everything. I was programmed that way :D
Fair point Mary.
Fair point Mary.
Don't think I didn't notice the edit. How double damn dare you. :D
NeoPa 32,534
Expert Mod 16PB
Don't think I didn't notice the edit. How double damn dare you. :D
Well - it was worth a try :D (I didn't tamper with your post notice).
Hi again
So! I haven't yet receved my book so mean while I'm still stuck knowing a little less than nothing about VBA programming.
Could there be anything done about the code giving an error when there are controlled objects on the form. For the moment I have a textbox that gets data depending of values from other controls. For example just ignoring those objects.
Thanks in advance
NeoPa 32,534
Expert Mod 16PB
I've changed the original code somewhat. Considering this is a function to clear unbound controls, it's only right that there should be a check to see if the control is unbound ;)
See if this works better for you. - 'ClearUnbound empties all controls on an unbound form.
-
Public Sub ClearUnbound(frmMe As Form)
-
Dim varCtrl As Variant
-
-
For Each varCtrl In frmMe.Controls
-
With varCtrl
-
Select Case .ControlType
-
Case acCheckBox, acComboBox, acListBox, acTextBox
-
If IsNull(.ControlSource) Then .Value = Null
-
End Select
-
End With
-
Next varCtrl
-
End Sub
Thanks for the response but now it dosen't clear anything??
Any other suggestions?
Thanks
NeoPa 32,534
Expert Mod 16PB
Sorry. I expect the check of (.ControlSource) should be for an empty string rather than Null. Try this amended version : - 'ClearUnbound empties all controls on an unbound form.
-
Public Sub ClearUnbound(frmMe As Form)
-
Dim varCtrl As Variant
-
-
For Each varCtrl In frmMe.Controls
-
With varCtrl
-
Select Case .ControlType
-
Case acCheckBox, acComboBox, acListBox, acTextBox
-
If .ControlSource = "" Then .Value = Null
-
End Select
-
End With
-
Next varCtrl
-
End Sub
IT WORKS!!!
Thanks a million : )
NeoPa 32,534
Expert Mod 16PB
Everyone sounds surprised when my code works! :D
Seriously, I'm pleased it's done the trick.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Gregory A Greenman |
last post by:
I'm trying to write a program in vb.net to automate filling out a
series of forms on a website. There are three forms I need to
fill out in sequence. The first one is urlencoded. My program is...
|
by: Norman Fritag |
last post by:
Hi there
I have a form wish is used to doubt check data been entered before it is
updated to the main table.
I structured the form into 3 tabs of which the first on represents the total
amount...
|
by: abdul bari |
last post by:
Hi
I have a standard html form which is generated by an XSL sheet. The
form data is submitted to the server and is passed on to file.aspx for
processing. However file.aspx is refreshed every 5...
|
by: Mark Waser |
last post by:
Hi all,
I'm trying to post multipart/form-data to a web page but seem to have
run into a wall. I'm familiar with RFC 1867 and have done this before (with
AOLServer and Tcl) but just can't seem...
|
by: tmax |
last post by:
PHP Pros:
I have a simple html form that submits data to a php script, which
processes it, and then redisplays the same page, but with a "thank you"
message in place of the html form. This is...
|
by: David P. Donahue |
last post by:
I have an ASP .NET website where users submit comments and, depending on
whether or not the web service accepting the comments returns an error,
the form uses this.page.registerstartupscript() to...
|
by: Msharma |
last post by:
Hello all,
This is my first flirtation with PHP and I could use some help on this.
This is what I'm trying to do. I capture data from an HTML form and catch the data in a PHP script. Now I want to...
|
by: smk17 |
last post by:
I've spent the last few minutes searching for this question and I
found an answer, but it wasn't quite what the client wanted.
I have a simple online form where the user needs to fill out five...
|
by: starter08 |
last post by:
Hi,
I have a C++ routine(client-side) which uploads an xml file to a web server by making a socket connection and sending all the post request through that socket.
On the server side I have a cgi...
|
by: Rina0 |
last post by:
Cybersecurity engineering is a specialized field that focuses on the design, development, and implementation of systems, processes, and technologies that protect against cyber threats and...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 2 August 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM)
The start time is equivalent to 19:00 (7PM) in Central...
|
by: erikbower65 |
last post by:
Using CodiumAI's pr-agent is simple and powerful. Follow these steps:
1. Install CodiumAI CLI: Ensure Node.js is installed, then run 'npm install -g codiumai' in the terminal.
2. Connect to...
|
by: linyimin |
last post by:
Spring Startup Analyzer generates an interactive Spring application startup report that lets you understand what contributes to the application startup time and helps to optimize it. Support for...
|
by: erikbower65 |
last post by:
Here's a concise step-by-step guide for manually installing IntelliJ IDEA:
1. Download: Visit the official JetBrains website and download the IntelliJ IDEA Community or Ultimate edition based on...
|
by: DJRhino1175 |
last post by:
When I run this code I get an error, its Run-time error# 424 Object required...This is my first attempt at doing something like this. I test the entire code and it worked until I added this -
If...
|
by: Rina0 |
last post by:
I am looking for a Python code to find the longest common subsequence of two strings. I found this blog post that describes the length of longest common subsequence problem and provides a solution in...
|
by: DJRhino |
last post by:
Private Sub CboDrawingID_BeforeUpdate(Cancel As Integer)
If = 310029923 Or 310030138 Or 310030152 Or 310030346 Or 310030348 Or _
310030356 Or 310030359 Or 310030362 Or...
|
by: DJRhino |
last post by:
Was curious if anyone else was having this same issue or not....
I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
| |