473,671 Members | 2,403 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

Seth Schrock
2,965 Recognized Expert Specialist
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 1389
Seth Schrock
2,965 Recognized Expert Specialist
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
3012
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 RaceCode (which might have values such as 1,3,5,7, etc), the second table is like a key for this RaceCode so it has two columns (1st one is 1,3,5,7, etc and 2nd one with description such as Caucasian, Hispanic, African American, Native American, etc)....
2
2430
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 value entered in the name column. Let's say a new column is entered with the value of name column as mickey. I want to create a table called mickey, with the help of triggers. I'm really new to this and i would like some help. Thanks in advance for...
1
6009
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
1565
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 the actual comments) about the customer account. I would like to have one form that gathers all this information; however, I would like it to write the data to 2 different tables. The form I am trying to use is based on the customer information...
0
1423
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. Using MS SQL 2000 t-sql. Existing table has the new table column characteristics and looks like this, FieldName Type Size Nulls column1 char 20 no
5
2627
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 otbl. How can I solve this error guys? Heres the code: Dim otbl As New ADOX.Table Dim ocat As New ADOX.Catalog otbl.Name = "Table1"
6
3145
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 it again the pivot table failed me. As i am using raw data as the data source, hence the number of rows changes everyday and therefore the datasource for the pivot table code cannot be fixed. How do i do this? ...
3
13431
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 any of the records from the table. The end goal is to give folks with very little computer literacy the ability to fill out a simple form and click a command button to add items to their inventory. That being said, I am unsure of how to get the...
1
1792
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? http://bytes.com/topic/visual-basic/answers/894647-access-vba-how-create-crosstab-table-using-two-queries#post3602456 thanks in advance.
26
2507
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 appreciated.
0
8478
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8919
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8599
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8670
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5696
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4409
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2813
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2052
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1810
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.