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

Reserved Error(-1104) 2

Status
Not open for further replies.

jimb0ne

Programmer
Oct 6, 2003
291
CA
I'm receiving this error when I call the edit method of a recordset object I have. Anyone have any idea what could be causing such an error? Or perhaps and idea as to what the error is?
 


docmd.openform "YearInfo", acNormal,,,acFormEdit,acHidden
Set TestDB2 = Forms!YearInfo.recordset
testdb2.findfirst "EmployeeID = " & EmployeeID

the error appears on the testdb2.findfirst line.
 
You probably need quotes around the field value
Code:
   testdb2.findfirst "EmployeeID = '" & EmployeeID & "'"
 
nope, not the quotes, only required for string values and EmployeeID is a numeric value. The odd thing is this error occurs not only on findfirst, but any time I try to use any property or method of the TestDB object. if I try to use .recordcount, I get the same error. Very unusual.

Thanks folks.
 
Try setting it to Forms!YearInfo.RecordsetClone

ProDev, MS Access Applications
Visit me at ==> Contact me at ==>lonniejohnson@prodev.us

May God bless you beyond your imagination!!!
 
docmd.openform "YearInfo", acNormal,,,acFormEdit,acHidden
Set TestDB2 = Forms!YearInfo.recordset
testdb2.findfirst "EmployeeID = " & EmployeeID

hmmm. Why are you opening a form?
is it to get a record?

why don't you go right to the recordset and not open the form?

dim db as database
dim rs as recordset
set db = Currentdb
set rs = db.openrecordset("SELECT tblEmployeeInfo.* FROM tblEmployeeInfo WHERE tblEmployeeInfo.EmployeeID = " & Me.EmployeeID


if rs.recordcount = 0 then
msgbox "Whoops!", vbokonly, "Test Box"
end if

Me.txtYear = rs!EmployeeYear

rs.close
db.close









 
oops! left a part out on building the recordset

set rs = db.openrecordset("SELECT tblEmployeeInfo.* FROM tblEmployeeInfo WHERE tblEmployeeInfo.EmployeeID = " & Me.EmployeeID, db.opensnapshot)
 
Just couple of long shots, disregard first part if you're using a97

Could it be a DAO/ADO confusion?

Added the disclaimer cause you haven't any provided information on the declaration of the recordset. If you're using a2k+ versions, you might need:
1 - to add a reference to Microsoft DAO 3.N Object Library (N representing a number, probably 6) How - in any module, use Tools | References, select the library.
2 - explicit declaration of the recordset:

[tt]dim rs as dao.recordset[/tt]

Forms recordsets are DAO and .FindFirst is a DAO method. If you're using later versions without explicit declaration, the recordset is declared as ADO, which would provide an error on the .FindFirst line, though I haven't seen this one (whats the error message?).

Could also be a missing/corrupt or whatever it's called, reference to the DAO library (even if you're not explicitly using DAO, Access/VBA will, when using for instance the "Find a record on my...." Combo, only it's using late binding - dim rs as object).

Agree fully with LonnieJohnson, the recordsetclone property is a better alternative than the recordset property.

Then - 'nother (possible) issue. Opening the form like this, makes the code continue after the docmd.open... statement. Just wondering, might it be that the YearInfo recordset isn't populated when you (try) retrieve it?

Could it possibly be an idea to perform the .findfirst in the other form, and pass whatever value back? (using acdialog) (if the issue is supposed to be opening the form showing the selected record, that might considere to be the preferred way)

jsrothaus might have a point in referencing the control explicitly, though I prefer using the "bang" version stead of the "dot" [tt]me!employeeID[/tt] - which arisises 'nother issue, form/report controls should not have the same name as the field their'e bound to - if this is the case, you might consider renaming the control (txtEmployeeID)

You haven't really elaborated much on what you wan't to achieve, so as you see, there's quite a quessing contest going on.

If none of this brings you any closer, please elaborate some more on what you want to achieve (including version, declarations, errmsg etc), and we'll give it our best try;-)

HTH Roy-Vidar
 
Hi Folks,
Thanks for the input, I actually found I was calling a function from within a function which was making the program reciprocate, which it wasn't supposed to do. At any rate, RoyVidar and jsrothaus, thanks a lot for the help. The reason I'm opening a form is becauase I'm reasonably new to Access programming, so I was using a blank form to access one of my tables. Looks as though the openrecordset method is probably the best way of doing that though. Thanks a bunch.

James
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top