Create xtab query by form ??

L

luanhoxung

Hi, folks !
I need a help.
I use a unbound form to create a Xtab query throught Click event of a
command button on form.
Althought the Xtab was created after Click event, I get the error '13'
- Type missmatch. I try to audit all the words but I don't see
anything wrong !
Can anyone help me explain this ?
Thanks for ur time.
Luan
Here is the code :

Private Sub Command13_Click()
Dim Db As Database
Dim strSQL As String
Dim qrf As QueryDefs

strSQL = "TRANSFORM '~' & Last([TLICHTAU.TIME]) & '~' &
Last([TCUOCTAU.F40FT]) & '~' & Last([TCUOCTAU.F20FT]) AS state" & _
" SELECT THANGTAU.HANGTAU, THANGTAU.TEN, TLICHTAU.ETD" & _
" FROM (THANGTAU INNER JOIN (TCUOCTAU INNER JOIN TPORT ON
TCUOCTAU.PORT = TPORT.id) ON THANGTAU.HANGTAU = TCUOCTAU.HTAU) INNER
JOIN TLICHTAU ON (TPORT.id = TLICHTAU.PORT) AND (THANGTAU.HANGTAU =
TLICHTAU.HTAU)" & _
" WHERE (((THANGTAU.HANGTAU) Like '" & Me.line1 & "')" _
& " And ((TPORT.PORT) Like '" & Me.port1 & "'))" _
& " GROUP BY THANGTAU.HANGTAU, THANGTAU.TEN, TLICHTAU.ETD" & _
" ORDER BY THANGTAU.HANGTAU" & " PIVOT TPORT.port;"

Set Db = CurrentDb
Db.QueryDefs.Delete "q1"
Set qrf = Db.CreateQueryDef("q1", strSQL)

Set Db = Nothing
Set qrf = Nothing

End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top