Bob P
Bob P

Reputation: 237

Adding records to a table from a list box using Visual Basic

I am trying to allow users to double click on an item in a List box and then have the selected value (and some related values using SQL) input into a table that I have ready.

I would post the code that I have but the truth is I don't even know where to start so ANY help would be massively appreciated.

My List box (listResult) has 3 columns that I would like to be input into my table (Stock Conversion).

Thanks in advance,

Bob P

Upvotes: 0

Views: 898

Answers (1)

Fionnuala
Fionnuala

Reputation: 91376

One possibility:

Dim qdf As QueryDef

'Temporary query
Set qdf = CurrentDb.CreateQueryDef( _
       "", "Insert Into Table1 (atext,anumber) values ([p1],[p2])")

qdf.Parameters("[p1]") = "abc"
qdf.Parameters("[p2]") = 20
qdf.Execute dbFailOnError

Upvotes: 1

Related Questions