Results 1 to 3 of 3
  1. #1
    KH Ahmed Bara is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Dec 2013
    Posts
    13

    Deactivating VBA Runtime Error

    HI
    am having an MS_Access 2010 Form containing a subform that i assign a continues row number as this

    Option Explicit

    Public Function fRowNum(Reset As Boolean) As Long
    Static I As Integer
    If Reset = True Then
    I = 0
    End If
    'Add Row Numbers to Continuous Forms:
    I = I + 1
    fRowNum = I
    End Function




    when ever i load the form, the line numbers uses to recall the last values just like auto number but i want it to restart from (1), i succeed by using reset code as Private Sub Form_Load()
    DoCmd.RunCommand acCmdReset


    but whenever i load the form i use to get runtime error '2046' i want to disable that any help? sorry for my English

  2. #2
    John_G is offline VIP
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2011
    Location
    Ottawa, ON (area)
    Posts
    2,615
    If you want to call your function when the form loads, and start at 1, use:

    fRowNum True

    in the Form_Load procedure, instead of DoCmd.RunCommand acCmdReset

  3. #3
    KH Ahmed Bara is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Dec 2013
    Posts
    13
    Thanks a lot is working perfectly.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 3
    Last Post: 02-26-2016, 12:34 PM
  2. Deactivating Records
    By Nixx1401 in forum Forms
    Replies: 2
    Last Post: 12-30-2015, 06:29 AM
  3. Replies: 2
    Last Post: 08-22-2015, 11:26 AM
  4. Replies: 2
    Last Post: 10-15-2014, 04:23 AM
  5. Replies: 13
    Last Post: 06-12-2012, 09:52 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums