?
Solved

insert unbound text and combo box value into a table

Posted on 2008-10-28
10
Medium Priority
?
1,543 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 1000 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
Industry Leaders: 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 1000 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

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

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

It’s the first day of March, the weather is starting to warm up and the excitement of the upcoming St. Patrick’s Day holiday can be felt throughout the world.
Did you know that more than 4 billion data records have been recorded as lost or stolen since 2013? It was a staggering number brought to our attention during last week’s ManageEngine webinar, where attendees received a comprehensive look at the ma…
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…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

719 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