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

How do I create a record in a table using information in form controls?

Seth Schrock
2,965 Expert 2GB
I'm creating a billing database and currently, I'm pulling records from the sales table using the current CustomerID, and two textboxes to give a date range as the criteria for the query. From here, I want to be able to create a record in the Invoices table with the CustomerID, StartDate, and EndDate from the form. The Invoices table is designed as follows:
Expand|Select|Wrap|Line Numbers
  1. tblInvoices
  2. InvoiceID   PK
  3. CustomerID
  4. BeginDate
  5. EndDate
At first I thought I would use an Append Query, but it looks like the information has to be from a datasource such as another table or SQL database. I could use an Update Query if I could have it update the new record since the InvoiceID is an AutoNumber field. What is the best way do to this?
Nov 9 '11 #1
1 1368
Seth Schrock
2,965 Expert 2GB
I found a method using VBA. The code is the following:
Expand|Select|Wrap|Line Numbers
  1. Dim dbBilling As DAO.Database
  2.     Dim rstInvoices As DAO.Recordset
  3.  
  4.     Set dbBilling = CurrentDb
  5.     Set rstInvoices = dbBilling.OpenRecordset("tblInvoices")
  6.  
  7.     rstInvoices.AddNew
  8.     rstInvoices("CustomerID").Value = Forms!frmCustomer!CustomerID
  9.     rstInvoices("BeginDate").Value = Forms!frmCustomer!txtStartDate
  10.     rstInvoices("EndDate").Value = Forms!frmCustomer!txtEndDate
  11.     rstInvoices.Update
Nov 10 '11 #2

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

Similar topics

2
by: Max | last post by:
Hi, I have the following problem. I want to insert records into one table using the combination of two other tables. Here is a simplified example: Let's say the first table has a column with...
2
by: lakuma | last post by:
Hi, I have a table called A (say) with columns called name, place, animal and thing. I would want to write an on insert trigger on this table, which would create a table with the name of the...
1
by: huntress | last post by:
I am trying to create pivot tables using VBA in Access 2003. Is this possible? How do I go about it?
3
by: Ciara9 | last post by:
I am using Access 2003 and have 2 tables. One has customer information in it (such as name,dates,amount, etc...) and the 2nd table is more of a Comments table (displays username, time and date, and...
0
by: cb123 | last post by:
Hello, Please bear with me I'm new to t-sql. I've had no luck trying to figure this out yet using sql code. I need to use an existing table (data dictionary) as input for creating a new table. ...
5
by: MarkTingson | last post by:
Hello guys, im having trouble with this line of code. I'm trying to create a table in access using this piece of code but it says 'Object is no longer valid.' and it points to ocat.Tables.Append...
6
by: nicolenwn | last post by:
Hi everyone(: I'm having trouble creating pivot tables using macros. First i tried recording it then running the exact same thing. It worked fine the first time but a week later when i tried...
3
by: rnashting | last post by:
Good Morning! I have created a form as well as a table, and would like to use the form to populate the table. I did not base the form off of the table, because I do not want the form to display...
1
by: miss D | last post by:
hi, i have posted this question here, regarding Access SQL i believe someone here is good in SQL. anyone can help me? ...
26
by: astro3ron | last post by:
I have a table with a number of fields. I'd like to select one of those fields using a form so I can sort the entries of that specific field. Not sure how to select fields at run time. Any help...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.