Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Viewing an imbedded query

Status
Not open for further replies.

MisterMan

Technical User
Jun 4, 2002
87
US
Hey all,

I am sorry for bothering everyone with this, as I feel it should be easy, but it is just not working.

I have an imbedded SQl query in VBA on the Onclick property of a button;

If IsNull(Me.Combo9) = True Or Me.Combo9 = "" Then
MsgBox "Please select from the list!", vbOKOnly, "Missing Data"
Me.Combo9.SetFocus
Exit Sub
End If

Dim db As Database, rst As Recordset, sql As String

sql = "SELECT * FROM IBSData WHERE [InternalNumber/AppropriationTitle] = '" & Me.Combo9 & "'"
Set db = CurrentDb
Set rst = db.OpenRecordset(sql)


Me.Combo9 = ""

Exit_Run_Click:
Exit Sub

Err_Run_Click:
MsgBox Err.Description
Resume Exit_Run_Click


But when I try to run this I get a "Too few paremters, expected 1" which doesn't make sense.

All I want to do is have the resulting SQl query show on the screen as a datasheet. I have no idea why this is not working.

Help?
 
Does the IBSData table have a field named InternalNumber/AppropriationTitle ?

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
There is probably something wrong with the query.
Plz check proper field name for [InternalNumber/AppropriationTitle] - just a suggestion.
Also try running the query outside the vba..directly from access.
 
The query works fine, and I decided to do a simpler version which merely pulls all the data from the table listed. I click the button now, and nothing happens...
 
if the sqlt is resqolved add it to the querydefs collection and open the query

Dim qdef As QueryDef
Set qdef = CurrentDb.CreateQueryDef("myquery", strSQL)
DoCmd.OpenQuery "myquery
 
Only problem with this is that I would have to delete myquery each time, no?
 
yes so!

CurrentDb.QueryDefs.Delete "myquery"


That or create a form or report or table to display your recordset.

either way you need to create an object.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top