I have a 5-tabbed form that is used to add records in five different tables. The tables are excel-linked. When I press the save button the records goes to different tables but the fields are not cleared. So I want a way to clear the fields after inserting the records. Pls Help!!!
7 5689
Your situations is a little unclear but, I'll answer the best i can. The simplest way to accomplish what you ask is to add the following to the OnClick event of your save button: -
Textbox1 = "" 'The name of each control on your form supplying a record.
-
Textbox2 = ""
-
etc.
-
OR -
Textbox1 = Null
-
Textbox2 = Null
-
This could also be done using a loop or by using DoCmd.gotorec,,AcNewRec if the 5 tabbed forms are linked to the 5 tables.
Hope this points you in the right direction,
Bender
Thank you very much for your help. Even though I had to go a bit deeper but I managed to solve it as follows: - Forms!Computer!TabCtl0.Pages!CPUInfo.Controls!cpu.Text = ""
Well for a minute I thought that worked but going on the backend I realised that putting that code in the OnClick button would make the fields in the table blank as well whereas I want it to save the records in the table and leave the form fields blank then go to next record. So the code is right but where do I put it because its not in the OnClick event?
Ok, it seems that all of your forms and there corresponding fields are linked to tables. What you ask could easily been done using DoCmd.
On the OnClick event try using: DoCmd.GoToRec,,AcNewRec.
This should save your record then move to a new record. This will save your records then clear the fields.
HTH,
Bender
I have tried that a long time ago to no help. I have an insert statement to insert values into the different tables and that works successfully. The only problem is after inserting the values the fields do not clear...
Ok, lets see if I understand your project.
None of your forms' record sources are link directly to a table and your using an insert query to update several tables via a command button. However, after changing a field (text = "") you also change the data in the table.
From what I understand, it seems like the insert query is running twice or your forms ARE linked to the tables and your running an insert query also. This would produce alot of duplicate entries and/or null records in your tables.
Please provide the code your using with your save records button and the record source of each table. This might shed some light on the problem.
Regards,
Bender
- Private Sub cmdSav_Click()
-
-
Dim ctl As Control
-
Dim stDocName As String
-
-
Dim conCars As ADODB.Connection
-
-
Set conCars = Application.CurrentProject.Connection
-
-
-
conCars.Execute "INSERT INTO Monitor(SerialNo, ManufacturerSerialNo, Make, " & _
-
"Model, DatePurchased, WarrantyPeriod, MonitorSize, " & _
-
"AssignedOfficer) VALUES('', '', '', '', '', '', '', '')"
-
-
conCars.Execute "INSERT INTO Officer(Ministry, Department, Division, AssignedOfficer, " & _
-
"OfficeNumber, TelephoneNumber) VALUES('', '', '', " & _
-
"'', '', '')"
-
-
conCars.Execute "INSERT INTO Printer(SerialNo, Make, Model, DatePurchased, " & _
-
"WarrantyPeriod, ManufacturerSerialNo, AssignedOfficer) VALUES('', '', '', " & _
-
"'', '', '', '')"
-
-
conCars.Execute "INSERT INTO Scanner(SerialNo, Make, Model, DatePurchased, " & _
-
"WarrantyPeriod, ManufacturerSerialNo, AssignedOfficer) VALUES('', '', '', " & _
-
"'', '', '', '')"
-
-
conCars.Execute "INSERT INTO Processor(SerialNo, ManufacturerSerialNo, Make, Model, " & _
-
"DatePurchased, WarrantyPeriod, CPURAM, Speed, " & _
-
"HDDSize, MouseMake, OperatingSystem, OSProductKey, AssignedOfficer) VALUES('', " & _
-
"'', '', '', '', '', '', '', '', '', '', '', '')"
-
-
'DoCmd.GoToRecord acDataForm, Me.Name, acNewRec
-
'DoCmd.DoMenuItem acFormBar, acRecordsMenu, 5, , acMenuVer70
-
conCars.Close
-
Set conCars = Nothing
-
-
End Sub
And the source object of each subform is the respective linked tables:
Processor, Scanner, Printer, Officer and Monitor
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Chumley the Walrus |
last post by:
I want to insert records into two tables with identical fields at
once, the below sql string is giving me an error at the comma " , "
between tblProline and Prolinebup, the 2 tables i want to...
|
by: Jack |
last post by:
Hi,
I am trying to get a thorough understanding of a code where a addition or
deletion of records can be done from a list of records. For addition part of
the form, data is being obtained from set...
|
by: Doslil |
last post by:
I have a form which is designed to only data entery.When i try to open
to form in the run form I have the following errors
1. when i open the form I get an error message saying "Access can't...
|
by: Pushpendra Vats |
last post by:
Hi ,
I am trying to insert records into database. I am trying
to write the following code.
On button1 click event i am inserting five records and
after that i am calling the update method of...
|
by: John |
last post by:
I have two tables in a 1:M relationship- the parent has 5 fields in the
primary key and the child 6 (these are actually pretty far downstream in
a complicated ER model, but the problem is between...
|
by: gouse |
last post by:
Hello Friends,
In a Table I am inserting more than 50,000 Records one by one. It was taking a lot of time . Is it There any good approach/solution for inserting records more than 50,000 one by one...
|
by: pramodrepaka |
last post by:
i am not able to add records with the help of ADODB. what is the problem i am not able to understand please help me. this is the code i written
In General Declaration
Dim cn As New...
|
by: ebindia0041 |
last post by:
This is like the bug from hell. It is kind of hard to explain, so
please bear with me.
Background Info: SQL Server 7.0, Asp.net 1.1 with c#
I'm inserting simple records into a table. But one...
|
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...
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
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...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
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,...
|
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...
| |