Object variable or with Block variable not set

  • Thread starter Thread starter spieters via AccessMonster.com
  • Start date Start date
S

spieters via AccessMonster.com

L.S.

I'm getting the message "Object variable or with Block variable not set"

Im working with a project using a SQL server 2000.
This is the code I'm using. I'm more or less used to MDB but this APD is my
first.

Is there something wrong in the coding?

Dim bdd As DAO.Database

Dim rs As DAO.Recordset

Dim SQL As Variant

Dim stLinkCriteria As String

Dim datHireDate As Date

Dim strTitle As String

If Me.voucher_personnum = "" Or IsNull(Me.voucher_personnum) Then

MsgBox ("Error:.. Please enter a valid Employee Number")

Me.voucher_personnum.SetFocus

Exit Sub

End If


Set bdd = CurrentDb

Set rs = bdd.OpenRecordset("bd_kronos_dbo_VP_TOTALS", dbOpenTable)

datHireDate = Me.voucher_date


' Read Kronos to display Info if present

Set rs = Nothing

SQL = "Select bd_kronos_dbo_personnum, bd_kronos_dbo_applydate " & _

"FROM bd_kronos_dbo_VP_TOTALS Where bd_kronos_dbo_applydate = #" &
datHireDate & "# And bd_kronos_dbo_personnum = '" & Me.voucher_personnum &
"'"

' Set rs = bdd.OpenRecordset(SQL)'



If rs.EOF Then
MsgBox ("Error:.. Employee nbr or voucher date not in Kronos")

Me.voucher_personnum.SetFocus

Me.voucher_date.SetFocus


Set rs = Nothing

Set bdd = Nothing

Exit Sub

End If



Me.Emplname = rs.Fields("personnum")

If [timeinseconds] / 3600 >= 14.3 Then

MsgBox ("Employee heeft recht op 2(twee) overwerkbonnen")

End If


If [timeinseconds] / 3600 <= 14.3 Then

MsgBox ("Employee heeft recht op 1 (één) overwerkbon")

End If

Set rs = Nothing

Set bdd = Nothing

End Sub


Thanks in advance for your cooperation!

Stella
 
There is no CurrentDb in an ADP project. If you want to, you can create a
DAO.Database object; however, a better idea would be to take a look at the
previous posts in this newsgroup to know how to code properly with ADP.

In your case, probably that you should use currentproject.connection.execute
method to open an ADO recordset on the table. As a start:

http://www.devguru.com:80/technologies/ado/quickref/connection_execute.html

http://groups.google.ca/group/micro...aramoutput+lafontaine&rnum=1#308987cda95ed87f

etc...
 
Back
Top