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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Run-Time 91 Error, Please Help!!!

Status
Not open for further replies.

LonC25

IS-IT--Management
Nov 19, 2002
62
0
0
US
I have a multiple form project, I get a Run-Time 91 Error on the "Set pstrCurrent" line. Can someone help me figure this out. I have been struggling with this for days now...

Thanks in advance.


Private Sub cmdSelect_Click()
Dim pstrSQL As String
Dim pstrFROM As String
Dim pstrFields As String
Dim pstrCurrent As Recordset
Dim pstrWHERE As String
Dim pstrORDERBY As String
Dim dbcurrent As Database
pstrFields = " *"

pstrFROM = " FROM tblCustomer"

pstrWHERE = " WHERE fldCustomerID =" & frmCustomerSelect.txtCustID.Text

pstrSQL = " SELECT" & pstrFields & pstrFROM & pstrWHERE

Set pstrCurrent = dbcurrent.OpenRecordset(pstrSQL)

MsgBox pstrSQL

frmtblCustomers.Show
 
Has the object dbcurrent been set yet? I can't see it. If it has not been set then you can't use it to set another object.

Thanks and Good Luck!

zemp
 
Code:
Set pstrCurrent = dbcurrent.OpenRecordset(pstrSQL)

You've declared dbcurrent prior to this line in the subroutine, but I can't see that you've actually done anything with it. I suspect that's your problem.

It looks like you're trying to run a query against a database without actually connecting to the database first.

--
Jonathan
 
dbcurrent is delcared as a Database in the Module.bas. Its Public
 
Well that's another problem. You've declared it as a Public variable in a different module while at the same time you've declared it again in cmdSelect_Click() as a private variable with a scope to just that subroutine.

If you remove the declaration in cmdSelect_Click(), it will probably work.

--
Jonathan
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top