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

Object Variable or with Block variable not set error

Status
Not open for further replies.

snoopy80

Technical User
Jun 27, 2001
106
I Keep having this error when I click on Newrecord button in my Access ADP form. "Object Variable or Block Variable Not Set". Could someone give me an advise, please. This is my code:

On Error GoTo Err_CMDNEW_Click


DoCmd.GoToRecord , , acNewRec
Dim dbs As Object
Dim qdf As Object
Set dbs = CurrentDb
dbs.QueryDefs.Refresh
Me.Refresh
If IsNull(Forms!frmaccount!!subfrmOrder!DOS) = False Then
Forms!frmaccount!!subfrmOrder!Cost = Forms!frmaccount!subfrmOrder!subfrmcost!total
End If

Exit_CMDNEW_Click:
Exit Sub

Err_CMDNEW_Click:
MsgBox Err.Description
Resume Exit_CMDNEW_Click

Appreciate your help and Happy THANKSGIVING
 
I didn't think ADPs supported DAO objects (CurrentDb and QueryDefs). Why are you attempting to refresh the querydefs?

What happens if you use:
Code:
On Error GoTo Err_CMDNEW_Click


    DoCmd.GoToRecord , , acNewRec
[green]    'Dim dbs As Object
    'Dim qdf As Object
    'Set dbs = CurrentDb
    'dbs.QueryDefs.Refresh[/green]
    Me.Refresh
    If IsNull(Forms!frmaccount!!subfrmOrder!DOS) = False Then
Forms!frmaccount!!subfrmOrder!Cost = Forms!frmaccount!subfrmOrder!subfrmcost!total
End If

Exit_CMDNEW_Click:
    Exit Sub

Err_CMDNEW_Click:
    MsgBox Err.Description
    Resume Exit_CMDNEW_Click

Duane
Hook'D on Access
MS Access MVP
 
Which line of code raises the error ?
Anyway I'd use this:
Code:
If Not IsNull(Forms!frmaccount!subfrmOrder.Form!DOS) Then
  Forms!frmaccount!subfrmOrder.Form!Cost = Forms!frmaccount!subfrmOrder.Form!subfrmcost.Form!total
End If

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top