VB: Print a Query Result in a MsgBox...

G

Guest

in the past days, John show me how to run a shell command from VB, now what
im triying to accomplish this:
- Run a shell script
- Run a SQL query, store the result in a variable called "k"
- Print the "k" variable content in a MessageBOX

This is basically the proccess: The shell create a new table record, and the
sql is for get the new record ID, and the MessageBOX will be used for display
the record ID just created

This is the code but i dont kwnow where it breaks...

Private Sub CmdRMSfile_Click()

Dim strCmd As String
Dim ds As Database
Dim dds As Recordset
Dim myY
Dim k As DAO.QueryDef

strCmd = """C:\xml2odbc\po.bat"""
Shell strCmd

Set ds = OpenDatabase("C:\OM-TEST\StoneEdge\SEOrdMan2002.mdb")
k = "select MAX(OrderNumber) from [Orders];"
Set dds = ds.OpenRecordset(k)
myY = dds!kk
MsgBox myY
ds.Close

End Sub


Thanks in advance.
 
G

Guest

got it... i miss a "select MAX(OrderNumber) as [kk] from [Orders];" in the
sql... query
Other question... how can I have the sql query to wait until the "Shell
strCmd" is done in order to be executed...?
 

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