Results 1 to 7 of 7
  1. #1
    pshoestir is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Aug 2015
    Posts
    11

    So Lost!!

    I am extremely new to programming and a have a piece of code that is not working for me. I have tried to upload my database as I think it would be much easier for someone with experience to look at it rather than me try to explain it. I am still getting acquainted with the lingo. However, MY file size is 1.53 MB and apparently there is a restriction of 55 kb allowed. I have pasted a dropbox link for the database. At any rate, what I am trying to accomplish is have the user enter information into a form, click a button and based upon the number that the user enters into an unbound text field on the form, it adds that many new records to the bound table. I have a looping code to accomplish this but it keeps giving me an error and referencing the first line of code. I have double checked the spelling and button name and don't see why it would not work or, at least why it won't move past the first line. Any help is appreciated.

    Here is the code too in case an error can be spotted without downloading the database.

    Private Sub cmdAddFLPurchaseOrders_Click()
    On Error GoTo cmdAddFLPurchaseOrders_Click_Err


    On Error Resume Next
    Dim i As Integer
    Dim FLPOTable As String
    Dim rs As DAO.Recordset
    FLPOTable = "tblLumberPurchases"
    Set rs = CurrentDb.OpenRecordset(FLPOTable)
    With rs


    For i = 1 To Me.NumPONeededFL - 1

    .AddNew
    .Fields!CompanyName = Me.CompanyName
    .Fields!Mill = Me.Mill
    .Fields!LumberProducts = Me.LumberProducts
    .Fields!MillPrice = Me.MillPrice
    .Fields!Plants = Me.Plant


    .Fields!Delivered = Me.Delivered
    .Update
    Next i
    .Close

    End With


    DoCmd.Requery ""
    Me.NumPONeededFL = ""




    cmdAddFLPurchaseOrders_Click_Exit:
    Exit Sub

    cmdAddFLPurchaseOrders_ClickErr:
    MsgBox Error$
    Resume cmdAddFLPurchaseOrders_Click_Exit

    End Sub




    Here is the dropbox link for the database being referenced.

    https://www.dropbox.com/s/u85fdg87s3...%29.accdb?dl=0

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,521
    You don't need code for this. Use queries and macros. They can do it all.

  3. #3
    pshoestir is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Aug 2015
    Posts
    11
    I would prefer code

  4. #4
    CJ_London is offline VIP
    Windows 8 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,397
    My guess is if you compare your first line

    On Error GoTo cmdAddFLPurchaseOrders_Click_Err

    with the error code it is referencing

    cmdAddFLPurchaseOrders_ClickErr:

    you can see the difference.

    I would also comment out the 'on error resume next' until you have debugged the code. And with this line 'active' there is little point in having an error handling routine anyway

    a tip regarding code layout - put all your dim statements before any code, i.e. don't embed them in the code, they become difficult to find

    and a couple of tips regarding seeking help
    1. 'giving me an error' is not at all helpful to responders who want to help you. Please provide the full error code and description.
    2. surround your code with code tags to preserve indentation - highlight code and click the # button - otherwise it becomes difficult to read and responders will not be prepared to waste their time trying to work it out

  5. #5
    pshoestir is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Aug 2015
    Posts
    11
    Thanks for the many tips Ajax. The error it is giving is Compile error: Label not defined. Also, I will remember to use the # button next time. I tried to highlight and tab over but it would not allow me to indent, now I know how. Thanks again.

  6. #6
    CJ_London is offline VIP
    Windows 8 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,397
    OK - so ou see why you have the error? the difference in spelling

  7. #7
    pshoestir is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Aug 2015
    Posts
    11
    Yes sir. Thank you for the help. I have it working now.

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

Similar Threads

  1. lost table
    By J Foley in forum Access
    Replies: 1
    Last Post: 12-22-2014, 04:23 AM
  2. i have lost everything!!!
    By ariansman in forum Access
    Replies: 3
    Last Post: 08-24-2014, 12:18 AM
  3. Lost VBA Code
    By DavidKond in forum Access
    Replies: 2
    Last Post: 01-30-2014, 12:26 AM
  4. Lost Network
    By chessico in forum Access
    Replies: 0
    Last Post: 08-11-2011, 06:10 AM
  5. Completly lost...
    By fairytalesrcute in forum Access
    Replies: 1
    Last Post: 05-14-2009, 09:24 AM

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