Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

UNION USING ADO Problem

I have a union of two fields of the same table and save the union at same table. Now when I accessed it using the DAO it works fine, but when I tried to use the ADO it will not work. WHy? Cant ADO access a union query?

[b]Sample Code:[/b]
[color=Blue]
Private Sub Execute(myID as long)
Dim rst As New ADODB.Recordset

rst.Open "SELECT UnionCode.myID, UnionCode.myCode, TblStockBatch.BatchCode FROM UnionCode LEFT JOIN TblStockBatch ON UnionCode.StockID = TblStockBatch.StockID WHERE UnionCode.StockID=" & Val(myID), ADOcon, adOpenKeyset, adLockOptimistic
If rst.RecordCount > 0 Then
Me.txtBarcode.Text = rst!myCode
Me.txtBatchCode.Text = IIf(IsNull(rst!BatchCode), "", rst!BatchCode)
Else
Me.txtBarcode.Text = ""
Me.txtBatchCode.Text = ""
End If
rst.Close
Set rst = Nothing
endif[/color]

Can I get help from here? Thank you so much in advance

Sign In or Register to comment.