Results 1 to 4 of 4
  1. #1
    Clint is offline Novice
    Windows 10 Office 365
    Join Date
    Jun 2020
    Posts
    2

    MS Access closes when trying to populate numeric fields from a form

    This code has worked for a long time and I'm not sure what to fix, I've narrowed it down to be my numeric fields causing there error, but haven't found a way for the data to be inserted.
    Here is the code:

    Private Sub SaveInvoice()


    'Write the records
    Dim db As Database
    Dim rst As Recordset
    Dim NewInvNbr As Long
    Set db = CurrentDb()

    strCrit = "[inv_id] > 351372"
    If IsNull(DLookup("inv_id", "inv_header", strCrit)) Then
    NewInvNbr = 1
    Else
    NewInvNbr = DMax("inv_id", "inv_header", strCrit) + 1
    End If

    'Save the header info
    selectstmt = "select * from inv_header"
    Set rst = db.OpenRecordset(selectstmt, dbOpenDynaset)

    rst.AddNew
    rst("mbr_id") = Me.cmbMemberID
    rst("inv_id") = NewInvNbr
    rst("total") = Me.fldTotal
    rst("cash") = Me.fldCash
    rst("Change") = Me.fldChange
    rst("cashtype") = Me.cmbPayType

    rst("workstation") = "COMPUTERNAME"

    rst("mbr_type") = DLookup("mbr_type", "members", "id = " + Str(Me.cmbMemberID.Value))

    rst.Update
    rst.Close
    End Sub

    Here is the setup of the table I'm trying to insert into:


    Any help would be greatly appreciated!

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,652
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    Clint is offline Novice
    Windows 10 Office 365
    Join Date
    Jun 2020
    Posts
    2

    Thumbs up

    Thank you! After rolling back the version, everything is working again.

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,652
    Happy to help!
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

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

Similar Threads

  1. Replies: 10
    Last Post: 07-16-2018, 08:00 AM
  2. Counting/totalling non-numeric fields
    By mpreston14 in forum Queries
    Replies: 2
    Last Post: 09-20-2013, 07:21 AM
  3. Replies: 8
    Last Post: 08-02-2012, 10:50 AM
  4. Replies: 6
    Last Post: 06-26-2012, 06:29 PM
  5. Change to Form Closes Access
    By jbhjm in forum Forms
    Replies: 5
    Last Post: 04-22-2009, 01:04 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