Could someone take a look at this code please?

alexi

Registered User.
Local time
Tomorrow, 05:16
Joined
Feb 26, 2003
Messages
65
i was told to put this code under On Requisite, but i dont know what that is so i put it under On Open.

Private Sub Form_Load()
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim qdf As QueryDef
'Note that YourDuerySQLstring should return one record
Set qdf = db.CreateQueryDef("", "SELECT Expr1 FROM qryActuals WHERE TaskNo =" & Chr(34) & Forms!frmAddJobEntry!frmAddJobEntrySubFormTasks!TaskNo & Chr(34))
Set rs = qdf.OpenRecordset(dbOpenDynaset)
rs.MoveFirst
Forms!frmAddJobEntry!frmAddJobEntrySubFormTasks!ActualCost = rs.Fields(11) 'where i=the column of your query holding the result you want
qdf.Close
rs.Close
db.Close
Set qdf = Nothing
Set rs = Nothing
Set db = Nothing

End Sub

except i cant get it workin.
im getting "Object Variable or With Block vairable not set" error???
 
Did you set the database object:

set db = currentdb
 
no i hadnt thanks for that :) however im now gettin a different error message.

Too Few Parameters. Expected 2

??
 
thanks for that i tried those tips bubt still didnt work
dont spose u could have a look at it?
 
I could try to give it a go. Post it and I'll look at it.
 
i cant get it small enough. only to just under 2 meg
can u get it by ur email?\
 
You have compacted it ? Just winzip it and then post it on this site. No need to send it through email.

E
 
ive compacted it and zipped it but it is 1.1 meg and the limit is 1 meg on this site. i cant get it any smaller?!
 
Make a copy of it, remove any unnecessary records and forms from the copy, compact it and try again.
 
I ran into the same error with the statements
Dim db As DAO.Database
Dim rs As DAO.Recordset
Try this.
While in the VB enviroment looking at the code, left click on TOOLS from the menu bar and select REFRENCES.
In the window that opens make sure that MICROSOFT DAO 3.6 is checked. If it wasnt, do so, then save/close. Reopen and try the code again, it should work. If not, try selecting the other DAO options, but the 3.6 is working for me.
 
Also make sure that the priority for DAO is above ADO if
it is selected.

Wayne
 

Users who are viewing this thread

Back
Top Bottom