vba code querys

  • Thread starter Thread starter johnny
  • Start date Start date
J

johnny

I tray to make a code that schould list from a datebase
named "bil data" in this rutine;


Private Sub Kommandoknap31_Click()
Dim db

Dim SQL
Dim rst
SQL = "SELECT [BIL DATA].[BIL NR], [BIL DATA].DATO,
[BIL DATA].DAG, [BIL DATA].LAND, [ORDRE DATA].[ORDRE NR],
[ORDRE DATA].ORDREGIVER, [ORDRE DATA].AFSENDER, [ORDRE
DATA].TILBRINGER, [ORDRE DATA].MODTAGER, [ORDRE
DATA].MÆRKNING, [ORDRE DATA].[MANKO/OVERTAL], [ORDRE
DATA].INDHOLD, [ORDRE DATA].KVITERET, [ORDRE DATA].[FÆRDIG
LÆSSET KL], [ORDRE DATA].[LÆSSET AF], [ORDRE
DATA].BEMÆRKNING, [ORDRE DATA].[KONTROLERET AF], [ORDRE
DATA].ARKIVER, [ORDRE DATA].[ANTAL/KG] FROM [BIL DATA]
INNER JOIN [ORDRE DATA] ON [BIL DATA].Id = [ORDRE DATA].Id
WHERE ((([ORDRE DATA].ARKIVER)=No));"

Debug.Print ; DATO; BIL_NR
End Sub

I got only the date from the field "dato" and only once
time. The tabel has a lot of dates in the field "dato".

Wath have I done wrong ???
 
You need to open a recordset:

Dim SQL As String
Dim rst As DAO.Recordset
SQL = "SELECT ...
Set rst = dbEngine(0)(0).OpenRecordset(SQL)
Do While Not rst.EOF
Debug.Print rst!DATO; rst!BIL_NR
rst.MoveNext
Loop
rst.Close
Set rst = Nothing

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

I tray to make a code that schould list from a datebase
named "bil data" in this rutine;


Private Sub Kommandoknap31_Click()
Dim db

Dim SQL
Dim rst
SQL = "SELECT [BIL DATA].[BIL NR], [BIL DATA].DATO,
[BIL DATA].DAG, [BIL DATA].LAND, [ORDRE DATA].[ORDRE NR],
[ORDRE DATA].ORDREGIVER, [ORDRE DATA].AFSENDER, [ORDRE
DATA].TILBRINGER, [ORDRE DATA].MODTAGER, [ORDRE
DATA].MÆRKNING, [ORDRE DATA].[MANKO/OVERTAL], [ORDRE
DATA].INDHOLD, [ORDRE DATA].KVITERET, [ORDRE DATA].[FÆRDIG
LÆSSET KL], [ORDRE DATA].[LÆSSET AF], [ORDRE
DATA].BEMÆRKNING, [ORDRE DATA].[KONTROLERET AF], [ORDRE
DATA].ARKIVER, [ORDRE DATA].[ANTAL/KG] FROM [BIL DATA]
INNER JOIN [ORDRE DATA] ON [BIL DATA].Id = [ORDRE DATA].Id
WHERE ((([ORDRE DATA].ARKIVER)=No));"

Debug.Print ; DATO; BIL_NR
End Sub

I got only the date from the field "dato" and only once
time. The tabel has a lot of dates in the field "dato".

Wath have I done wrong ???
 
If liste21 is a listbox on your form, just set its RowSource property to the
name of your table. No code needed.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

"johnny" <[email protected]>
wrote in message Hello thangs alot
but hou to put all the rows into liste21
thangs for anser
 
Back
Top