Open result from datasheet view

tran_laca

New member
Local time
Today, 21:07
Joined
Nov 23, 2000
Messages
5
Hi all ..I have a question ...How can I see the result from datasheet view from the code below ...In the query we can see the datasheet view result but for the VBA code ..I have no idea how to sort the result as datasheet view ..

Dim db As Database
Dim rs As Recordset
Dim empnum As Long
Dim strsql As String
Set db = CurrentDb()
empnum = 10248
strsql = "select * from Orders where [OrderID]= " & empnum & ";"
Set rs = db.OpenRecordset(strsql)

How can I see the result in datasheet view of recordset rs

thanks ...
 
Hi Tran

What about using the query definition for displaying the result. Would it solve your problem?
(The error handling is for the case that the query definition already exist)

Public Sub Test()
Dim db As DAO.Database
Dim qd As DAO.QueryDef
Dim strSql As String

strSql = "Select * from [Switchboard Items] where SwitchboardID = 1"
Set db = CurrentDb
On Error Resume Next
Set qd = db.CreateQueryDef("Temp", strSql)
Set qd = db.QueryDefs("temp")
If Not (Err.Number = 0) Then qd.SQL = strSql
DoCmd.OpenQuery "temp"

End Sub
 
hi Kaspi

that solved my problem ...thank you alot for your help ....

Laca
smile.gif
 

Users who are viewing this thread

Back
Top Bottom