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

Inputting info from a form into two tables

Hi, I have been trying to figure this out for hours, but can't seem to get it. I have a form where the administrator inputs someone elses personal info (FirstName, lastName, email, phone#, etc.) and when they click enter, I have it so a new entry is created in my Volunteer table. What i would like to do it, is when the admin clicks the enter button, a new entry will be made in the Password table. When a new record is added to the Volunteer table, the primary key is the ID which is an autonumber. The password table is linked by foreign key to the Volunteer table by a UserID which is equal to the ID primary key in the User table. My goal was to click enter, create the new entry in the Volunteer table, then open the new recordset and create a new entry in the password table, with the UserID = ID and the username and password being equal to the first and last names respectively. This would simply be the default username and password for the user until they logged in themselves and changed their username and password. I tried doing this in VBA by attempting to select the largest ID number (largest being the most recent) and then using INSERT INTO to put the into into the password table. What I atttempted is below.


Private Sub Enter_Click()

DoCmd.GoToRecord , , acNewRec
Me.TextNew1.Value = Me.TextFirstName.Value
Me.TextNew2.Value = Me.TextLastName.Value

DoCmd.OpenTable "Password"
DoCmd.GoToRecord , , acNewRec

DoCmd.RunSQL "INSERT INTO Password(UserID, UserName, Password) SELECT Max(Volunteer.ID), Volunteer.FirstName, Volunteer.LastName FROM Volunteer;"

End Sub


I appreciate any help.

-Taylor
Apr 8 '08 #1
1 1420
I modified my code, so that it looks like what's below. I know the query works because i can run it by itself to append the Password table (i just have to enter the Volunteer.ID value). However, when i actually use the form, i get an error after it runs through the query that says "Run-time error '13': Type Mismatch" and i do not know what this means nor do i understand how to fix it. Any help?


Thanks,

Taylor



Private Sub Enter_Click()

DoCmd.GoToRecord , , acNewRec
Me.TextNew1.Value = Me.TextFirstName.Value
Me.TextNew2.Value = Me.TextLastName.Value

DoCmd.SetWarnings False
DoCmd.RunSQL "INSERT INTO Password(UserID,UserName,Password) SELECT Volunteer.ID, New.FirstName, New.LastName FROM Volunteer WHERE ((Volunteer.ID) = [Forms]![Volunteer]![Text67])"
DoCmd.SetWarnings True

End Sub
Apr 10 '08 #2

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

Similar topics

0
by: Marceia | last post by:
hello! I am developing a database that contains 2 tables: Attorney Table and Insured Table. I have a form (form1) that inputs data to both tables. Here's my challenge: I want to create a...
4
by: Christopher Brandsdal | last post by:
Hi! I have a delicatg problem.... I have made a registration form for adding my friends information in a database. The problem is that I want to connect the persons with companies in the same...
4
by: Alex | last post by:
I have searched the boards but I have not found what I am looking for yet. I have a form with two combo boxes. When the user makes a selection in both of the combo boxes the information will...
1
by: Mr. B | last post by:
VB.net 2003 c/w Framework 1.1 and MS Access db We have a commercial program that does our Acounting and Time Sheets (Timberline). At least once a day our Accounting department runs a Script...
1
by: HarryMangurian | last post by:
I set up an OLEDB connection, adapter, and dataset on my opening form. I want to input the Data Source and replace the DS supplied at design time with a string variable (I will probably use an...
2
by: dBNovice | last post by:
Hi all! I have 3 separate forms: Tasks, Subtasks, and Elements. All 3 is related by TaskId and Subtasks and Elements are related by SubtaskID. In the DB after I add a task, I want to be able to...
15
by: Cheryl Langdon | last post by:
Hello everyone, This is my first attempt at getting help in this manner. Please forgive me if this is an inappropriate request. I suddenly find myself in urgent need of instruction on how to...
1
by: tjerhoff | last post by:
Hello, I am pretty new to Access and have a question. I am setting up a database that will track production info. All I want to do is have a FORM that will allow me to input several data fields...
0
by: ashes | last post by:
Hi all, In Ms Access, I have a Customer table and a Credit Card table. The CustomerID field is a primary key in the Credit Card table. Both tables already have sample data in it. So, when a...
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...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
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$) { } ...
0
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...
0
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...
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:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.