473,407 Members | 2,546 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,407 software developers and data experts.

Adding records to multiple tables

I am trying to add a record to multiple tables at the same time. My current Code created multiple records in the same table.

I am trying two different methods with no results:

Public Sub txtSerialNumber_Enter()

Dim txtLotNumber As String
Dim txtSerialNumber As String
'Dim db As Database
'Set db = OpenDatabase("Modem.mdb")
'Dim Tbl As Recordset
'Set Tbl = Modem.OpenRecordset("TblLotNumber", dbOpenDynaset)


'txtSerialNumber = Me!txtSerialNumber
'Me!txtSerialNumber.
'txtLotNumber = Format(Now, "mm/dd/yyyy")
'Me!txtLotNumber.AddNew
'txtLotNumber = Me!txtLotNumber
'txtSerialNumber
'Me!txtLotNumber.Update

'For Each tbl In Array
'("TblLotNumber", "TblIncomingInspection", "TblFlashTest", "TblFunctionalTest")
'CurrentDb.Execute "INSERT INTO TblLotNumber (Me!txtSerialNumber,LotNumber)VALUES &" '"(Me!txtSerialNumber & txtLotNumber)&"'""
'CurrentDb.Execute "INSERT INTO TblIncomingInspection (" & Me!txtSerialNumber & ",'" & txtLotNumber & "') VALUES (" & Me!txtSerialNumber & ",'" & txtLotNumber & "')"
'CurrentDb.Execute "INSERT INTO TblFlashTest (SerialNumber,LotNumber) VALUES (" & Me!txtSerialNumber & ",'" & txtLotNumber & "')"
'CurrentDb.Execute "INSERT INTO TblFunctionalTest (SerialNumber,LotNumber) VALUES (" & Me!txtSerialNumber & ",'" & txtLotNumber & "')"
'CurrentDb.Updatable

End Sub
Nov 7 '06 #1
1 2914
MMcCarthy
14,534 Expert Mod 8TB
Assumptions made:

Each table has two fields called SerialNumber datatype text and LotNumber datatype date that defaults to todays date.

Try this code:

Expand|Select|Wrap|Line Numbers
  1.  
  2. Public Sub txtSerialNumber_Enter()
  3.  
  4.   DoCmd.RunSQL "INSERT INTO TblLotNumber (SerialNumber, LotNumber) VALUES ('" & _
  5.   Me!txtSerialNumber & "', " Format(Now, "mm/dd/yyyy" & ")"
  6.   DoCmd.RunSQL "INSERT INTO TblIncomingInspection (SerialNumber, LotNumber) VALUES ('" & _
  7.   Me!txtSerialNumber & "', " Format(Now, "mm/dd/yyyy" & ")"
  8.   DoCmd.RunSQL "INSERT INTO TblFlashTest (SerialNumber, LotNumber) VALUES ('" & _
  9.   Me!txtSerialNumber & "', " Format(Now, "mm/dd/yyyy" & ")"
  10.   DoCmd.RunSQL "INSERT INTO TblFunctionalTest (SerialNumber, LotNumber) VALUES ('" & _
  11.   Me!txtSerialNumber & "', " Format(Now, "mm/dd/yyyy" & ")"
  12.  
  13. End Sub
  14.  
  15.  
Nov 7 '06 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: Jamie Fryatt | last post by:
Hi everyone, here's what id like to do. I have a table with 2 fields, name and value I need to be able to add multiple records quickly, for example I need to add name value abc 1...
2
by: dixie | last post by:
I have a report which is printed daily. It is a list of people. A person can be put on this list for one day, which is easyily achieved from a simple form. My problem is that a person can also...
5
by: Sami | last post by:
Please bear with me, and if you answer this question, please do it step by step. I am new at Access, not at all sophisticated. I am using Office XP. This will need to be read in Access for...
4
by: Mike Hnatt | last post by:
My goal is to get data from an XML file into a couple of tables in an Access database. The XML file is a little complex so I need control over what I do (I can't just read it into a dataset). ...
6
by: Rudy | last post by:
Hi all, I know this is easy, just can't seem to get it. I have a windows form, and a text box, with a value already in it. I need to add that value to a table. It's just one value, so the entire...
8
by: shumaker | last post by:
I'm wondering if adding an autonumber primary key will improve the performance of a multiuser access database on a network share. I have a website that lists many tips for improving performance of...
11
by: shriil | last post by:
Hi I have this database that calculates and stores the incentive amount earned by employees of a particular department. Each record is entered by entering the Date, Shift (morn, eve, or night)...
2
by: Steve | last post by:
I have zero experience with ODBC. If I have an Access frontend connected to a SQL Database using ODBC, are the tables connected like a frontend/backend Access database where the the tables you see...
2
by: jjwiet | last post by:
Hello, I use access 2003 and attempting to export/copy records between two access databases (almost identical) with multiple tables (both databases having the same relations between the tables)....
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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:
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
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...
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
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.