Object variable not set or block width not set error

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • MarkAllison
    New Member
    • Oct 2006
    • 1

    #1

    Object variable not set or block width not set error

    Hi, can anyone help me before I slit my wrists?!?!

    I am trying to create a procedure in an Access 97 database, that basically creates a new record in a table called "Discrepancies" , with an ID number 1 digit higher than the last record in the table. The name of the ID field is "DRNo". The code I am using is as follows, but I keep getting the error message, "Object variable not set or Block Width not set". This is my code:

    Dim dbWILAdb As Database, rsWILArs As Recordset, rsWILArt As Recordset, rsWILAru As Recordset

    Dim DRNo As Long


    'find required discrepancy number
    rsWILAru.MoveLa st
    DRNo = rsWILAru![DR No] + 1

    DoCmd.GoToRecor d , , acNewRec
    [DRNo] = DRNo

    If anyone can hlep me sort this problem, I will be eternally grateful!

    Cheers

    Mark
  • Killer42
    Recognized Expert Expert
    • Oct 2006
    • 8429

    #2
    Originally posted by MarkAllison
    Hi, can anyone help me before I slit my wrists?!?!

    ...
    I don't know that I can be much help, but something did catch my eye. In this code...
    Code:
           DRNo = rsWILAru![[b]DR No[/b]] + 1
            
            DoCmd.GoToRecord , , acNewRec
            [[b]DRNo[/b]] = DRNo
    Shouldn't the two highlighted field names be the same?

    Comment

    Working...