Selecting records

nat22

Registered User.
Local time
Today, 05:25
Joined
Jan 16, 2006
Messages
16
Hello everyone,
I am new one in Access programing so I will be grateful if someone can help me.The situation is this:I have main form frmOdabirOpreme.With button cmdNapajanje I open a new form frmNapajanje.On this form I have listBox lstNapajanje in which RowSource I have put - SELECT Napajanje.Referenca, Napajanje.Opis FROM Napajanje;(it is from Table Napajanje and it has two fields -Referenca and Opis). On this lstNapajanje I can see few records from Table Napajanje which I do not change.Now I want to select one of these records (by DoubleClick event on lstNpajanje) and copy it to another Table OdabranaOprema (which is connected to Excel file as invoice).
What is the best way to do this?

thanks,

I have tried something like this!

Private Sub lstNapajanje_DblClick(Cancel As Integer)


Dim db As Database
Dim strSQL As String

'create SQL to append records
strSQL = "INSERT INTO OdabranaOprema (Referenca, Opis ) " _
& " SELECT " & Referenca & ", Opis " _
& " FROM Napajanje " _
& " ORDER BY Referenca;"
'run the SQL statement
CurrentDb.Execute strSQL
'refresh the table definitions with records added by other persons/processes
CurrentDb.TableDefs.Refresh
'wake-up call for Access
DoEvents
'requery the subform



Set rsOdabranaOprema = Nothing

End Sub
 

Users who are viewing this thread

Back
Top Bottom