Inputbox with 3 values (1 Viewer)

jpl458

Well-known member
Local time
Today, 14:04
Joined
Mar 30, 2012
Messages
1,038
I have a form that allows the users to add or delete records from very small tables that are used as reference. One of the tables is a vehicle table (Vhicltbl. Here is the code I am using for the addition of a vehicle to that table. I need to end Make, Model, and VIN.

Code:
XNew = InputBox("Enter new Vehicle", "Add new Vehicle")
XSQL = "INSERT INTO Vehicltbl (Make) VALUES, (Model) Values ('" & XNew & "')"
CurrentDb.Execute XSQL, dbFailOnError
setupvehicleslb.Requery

When the inputbox opens there is only one field, and I can't figure out how to make it so I can enter the 3 fields.
In addition, the inset bombs with a syntax error on the CurrentDb.execute XSQL line.
 

cheekybuddha

AWF VIP
Local time
Today, 22:04
Joined
Jul 21, 2014
Messages
2,280
In addition, the inset bombs with a syntax error on the CurrentDb.execute XSQL line.
That's because the syntax is wrong.

To do what you want, you will need to create a new form to pop up where you have the InputBox with textboxes for each field.

Then you will want to create SQL that looks like:
SQL:
INSERT INTO Vehicltbl (Make, Model) Values ('New Make', 'New Model');

BUT...
If you use comboboxes on your form for Make and Model, you can use their NotInList events to add a new single value to each field.

Makes should be a separate lookup table.

Much simpler/better
 

Users who are viewing this thread

Top Bottom