Solved

insert unbound text and combo box value into a table

Posted on 2008-10-28
10
1,535 Views
Last Modified: 2013-11-28
Hello,

There are several answers listed to this question, but they are too complicated for me.  Therefore can someone suggest a simple answer.  I am also very new to vb.

I have a form and a subform.  Within the subform I have one combo box and one text box.  When I input these values, I want to add a new record with these values to an existing table.  I have a command button to do this.

Thank you in advance
Joy
0
Comment
Question by:joygomez
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
  • 2
10 Comments
 
LVL 3

Expert Comment

by:coleventures
ID: 22827856
My example:
Created table (Table1) with two fields   combofield and textfield
Created form (frmTest) with two fields   combo1 and txtfield
Form also has a button that runs the query (Query1)

So, when you choose from the combobox and then enter into the text field you hit the button to run the APPEND QUERY (Query1) the info you selected/entered is appended to the destination table (Table1).

Here is the literal SQL code for the Query1

INSERT INTO Table1 ( combofield, textfield )
SELECT [forms]![frmTest]![combo1] AS Expr1, [forms]![frmTest]![txtfield] AS Expr2;


RGC
0
 
LVL 42

Accepted Solution

by:
dqmq earned 250 total points
ID: 22828158
Put this into your command button on_click event.  Replace uppercase words with the appropriate names.

dim SQL as string
sql = "insert into YOURTABLE (COL1, COL2)  values ('" & me.COMBOBOX & "','" me.TEXTBOX & "')"
currentdb.execute (SQL)



           
0
 

Author Comment

by:joygomez
ID: 22831035
dqmq,
this is what I am looking for.  however it gives me a syntax error.  here is the code.
My table name is "Scans Main" with two fields "Barcode" & "OS".  I have a form with a text field "Text12"  and a combobox "Combo14".  I do not see where I am going wrong.

Private Sub Command0_Click()
Dim SQL As String
sql = "insert into Scans Main (Barcode, OS)  values ('" & me.COMBO14 & "','" me.Text12 & "')"
CurrentDb.Execute (SQL)
End Sub
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:joygomez
ID: 22831091
dqmq,
I got passed the above problem, but now I have a new error "run time error 3134: Syntax error in Insert ito statement"
0
 

Author Comment

by:joygomez
ID: 22831188
i just realized that there were no points given.  how do i get these points to you.
0
 
LVL 3

Assisted Solution

by:coleventures
coleventures earned 250 total points
ID: 22831565
sql = "insert into Scans Main (Barcode, OS)  values ('" & me.COMBO14 & "','" me.Text12 & "')"

You forgot the '&' before me.Text12

sql = "insert into Scans Main (Barcode, OS)  values ('" & me.COMBO14 & "','" & me.Text12 & "')"
0
 
LVL 42

Expert Comment

by:dqmq
ID: 22831910
joygomez,
Communtiy Support can reassign points for you.  Contact them or post your intentions in this thread and they will take care of it.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I see at least one EE question a week that pertains to using temporary tables in MS Access.  But surprisingly, I was unable to find a single article devoted solely to this topic. I don’t intend to describe all of the uses of temporary tables in t…
This article describes two methods for creating a combo box that can be used to add new items to the row source -- one for simple lookup tables, and one for a more complex row source where the new item needs data for several fields.
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

756 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question