Solved

insert unbound text and combo box value into a table

Posted on 2008-10-28
10
1,536 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
Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

 

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

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

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

Suggested Solutions

Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
Access custom database properties are useful for storing miscellaneous bits of information in a format that persists through database closing and reopening.  This article shows how to create and use them.
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 specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…

734 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