Moritz
Moritz

Reputation: 389

Set rowsource on form load (Access, SQL)

I try to set the rowsource of a listbox on form load but I can't get it to work. I have 3 different forms which can load another form via a button. This single form display some records based on the "ID_Projekttyp" which comes from the 3 main forms. The "ID_Projekttyp" will be provided by openargs.

Private Sub Form_Load()
varSplitString = Split(Me.OpenArgs, "|")
TempVar = CInt(varSplitString(1))
MsgBox TempVar
strSQL = " SELECT tbl_Projektphasen.Bezeichnung, tbl_Projekttypen.ID_Projekttypen " & _
" FROM tbl_Projektphasen INNER JOIN tbl_Projekttypen ON tbl_Projektphasen.ID_Projektphasen = tbl_Projekttypen.moeglicheProjektphasen.Value " & _
" WHERE (((tbl_Projekttypen.ID_Projekttypen)=" & TempVar
Me.Phasenbezeichnung.RowSource = strSQL
Me.Phasenbezeichnung.Requery
End Sub

The messagebox returns 3 (as example which is working so the error must be inside the sql statement but I can't find it.

Anyone can help?

Upvotes: 0

Views: 1853

Answers (1)

Eid Morsy
Eid Morsy

Reputation: 966

Remove all parentheses in where clause to make it clear (you have 3 before where and one after which is not correct)

" WHERE tbl_Projekttypen.ID_Projekttypen=" & TempVar

Upvotes: 1

Related Questions