Noob_Za1B00t
New member
- Local time
- Today, 12:37
- Joined
- Aug 5, 2012
- Messages
- 5
Hi all
I'm new to microsoft access and vba programming. So to start i made two tables. One called customers with these fields:
CustId(Primary Key)
Firstname
Lastname
Company
Email
The other called Orders with these fields:
OrderId(Primary Key)
OrderDate
CustId(Foreign Key)
PaymentMethod
I have two forms. In the customers form there are textboxes that get firstname, lastname etc and a button. In the onclick event on the button I have this code:
The thing I want to do is get a record entered into the orders table with the CustId matching the CustId in the Customers table when I click the button.
Any help would be appreciated.
I'm new to microsoft access and vba programming. So to start i made two tables. One called customers with these fields:
CustId(Primary Key)
Firstname
Lastname
Company
The other called Orders with these fields:
OrderId(Primary Key)
OrderDate
CustId(Foreign Key)
PaymentMethod
I have two forms. In the customers form there are textboxes that get firstname, lastname etc and a button. In the onclick event on the button I have this code:
Code:
Private Sub cmdDone_Click()
Dim mySql As String
mySql = "INSERT INTO Customers (FirstName, LastName, Company, Email) VALUES (txtFirst.Value, txtLast.Value, txtCompany.Value, txtEmail.Value)"
DoCmd.RunSQL mySql
Forms![frmOrder]![cmbCust].Requery
DoCmd.Close acForm, "frmCust", acSaveYes
End Sub
Any help would be appreciated.