Results 1 to 12 of 12
  1. #1
    mnaem02 is offline Novice
    Windows 10 Access 2016
    Join Date
    Oct 2017
    Posts
    24

    After Update tqo or more field update

    I want to update more fields with afterupdate but getting error



    Private Sub Product_AfterUpdate()


    SupplierBarcode = DLookup("VBarCode", "InventoryProducts", " ProductName = " & "Product")


    OurBarcode = DLookup("PID", "InventoryProducts", " ProductName = " & "Product")


    End Sub

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,772
    Assuming ProductName is a text type field, the parameter needs apostrophe delimiters. What is Product - a textbox on form?


    SupplierBarcode = DLookup("VBarCode", "InventoryProducts", "ProductName = '" & Product & "'")


    OurBarcode = DLookup("PID", "InventoryProducts", "ProductName = '" & Product & "'")
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    mnaem02 is offline Novice
    Windows 10 Access 2016
    Join Date
    Oct 2017
    Posts
    24
    I checkd seperately this working fine alone

    SupplierBarcode = DLookup("VBarCode", "InventoryProducts", " ProductName = " & "Product")


    Error is from here

    OurBarcode = DLookup("PID", "InventoryProducts", " ProductName = " & "Product")

  4. #4
    mnaem02 is offline Novice
    Windows 10 Access 2016
    Join Date
    Oct 2017
    Posts
    24
    PID is number i have removed comma no working fine OurBarcode = DLookup(PID, "InventoryProducts", " ProductName = " & "Product")

    now when i select big number from the combobox of form it is giving error "Value you have entered is not valid ,you may have entered text in a numeric which is not i have checked and number that is larger than field size PERMITS

    how can i change "
    number that is larger than field size PERMITS" in the form although no error in the table

  5. #5
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,772
    I really don't understand how "Product" in quote marks can produce correct results.

    What error are you getting?

    If you want to provide db for analysis, follow instructions at bottom of my post.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  6. #6
    mnaem02 is offline Novice
    Windows 10 Access 2016
    Join Date
    Oct 2017
    Posts
    24

    File attached for your reference

    When i select Product than Supplier barcode updated fine, now similarly i want to update "ourbarcode" but it is giving value 2 i dont know from where it is picking.


    after solving above problem I will update 3 "Unit Price" field from after update of products

    Appreciated and thanks for the help
    Attached Files Attached Files

  7. #7
    mnaem02 is offline Novice
    Windows 10 Access 2016
    Join Date
    Oct 2017
    Posts
    24
    now working fine with this code thanks for the support

    Private Sub Product_AfterUpdate()


    SupplierBarcode = DLookup("VBarCode", "InventoryProducts", " ProductName = " & "Product")
    OurBarcode = DLookup("PID", "InventoryProducts", " ProductName = " & "Product")
    UnitPrice = DLookup("Cost", "InventoryProducts", " ProductName = " & "Product")
    End Sub

  8. #8
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,772
    Well, that looks like the code you started with. I downloaded db and tested the existing code. It was missing quotes around PID.

    I learned something new. I had not expected the "Product" parameter to work yet it does. Also works without concatenation.

    SupplierBarcode = DLookup("VBarCode", "InventoryProducts", "ProductName = Product")
    OurBarcode = DLookup("PID", "InventoryProducts", "ProductName = Product")
    UnitPrice = DLookup("Cost", "InventoryProducts", "ProductName = Product")
    Last edited by June7; 10-05-2017 at 03:25 PM.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  9. #9
    mnaem02 is offline Novice
    Windows 10 Access 2016
    Join Date
    Oct 2017
    Posts
    24
    Table InventoryProducts Field UnitsMeasuretotal(Double General Number) Field (UnitsMeasure)(Text)
    In Form if i select field (UnitMeasure) then UnitmeasureTotal should be updated

    Bleow VBA code afterafdate giving value 1

    Private Sub UnitsMeasure_AfterUpdate()


    UnitsMeasureTotal = DLookup("UnitsMeasureTotal", "InventoryProducts", " UnitsMeasure = " & " UnitsMeasure ")


    End Sub

  10. #10
    mnaem02 is offline Novice
    Windows 10 Access 2016
    Join Date
    Oct 2017
    Posts
    24
    Same sheet , which i have previously attached

    can u tell me quotes rule ?

  11. #11
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,772
    Shouldn't that parameter be "Product" also and not "UnitsMeasure"?

    Why are you saving ProductName instead BID into PODetails? Why duplicating all this data into PODetails?

    DLookup is not really best approach for this. Product combobox could be multi-column. Set its properties:

    RowSource: SELECT InventoryProducts.BID, InventoryProducts.ProductName, InventoryProducts.PID, InventoryProducts.Vendors, InventoryProducts.VBarCode, InventoryProducts.Cost, InventoryProducts.UnitsMeasure, InventoryProducts.UnitsMeasuretotal
    FROM InventoryProducts;

    BoundColumn: either 1 or 2 depending on whether you save BID or ProductName

    ColumnCount: 8

    ColumnWidths: 0";1";0";0";0";0";0";0"

    Then code references combobox column index. Index begins with 0:
    OurBarcode = Me.Product.Column(2)
    SupplierBarcode = Me.Product.Column(4)
    UnitPrice = Me.Product.Column(5)
    UnitsMeasure = Me.Product.Column(6)
    UnitsMeasureTotal = Me.Product.Column(7)

    If you want to pull values from the InventoryProducts record, why are these even comboboxes? Why not locked textboxes that users cannot edit? Why even save these data into PODetails? Just save InventoryProducts BID primary key as foreign key into PODetails and retrieve the related info in queries.

    Why do you have PID field in InventoryProducts as well as PID autonumber in PODetails also PID in POEntry? Advise not to use same field name in multiple tables. Also advise no spaces in names.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  12. #12
    mnaem02 is offline Novice
    Windows 10 Access 2016
    Join Date
    Oct 2017
    Posts
    24
    i am trying to make purchase order(PO) form that’s why saving information in “PO detail” which can be traceable that from which supplier we have made which product. After PO I will make form for goods received based on PO.
    PO is the main for tracing quantity order PID I have made but if no use later I will remove
    Textboxes only pull data I thin not save in field and I want to save data in PO detail
    Advise not to use same field name in multiple tables. Also advise no spaces in names. Notedi am trying to make purchase order(PO) form that’s why saving information in “PO detail” which can be traceable that from which supplier we have made which product. After PO I will make form for goods received based on PO.
    PO is the main for tracing quantity order PID I have made but if no use later I will remove
    Textboxes only pull data I thin not save in field and I want to save data in PO detail
    Advise not to use same field name in multiple tables. Also advise no spaces in names. Noted

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

Similar Threads

  1. Replies: 2
    Last Post: 02-23-2017, 10:46 AM
  2. Replies: 1
    Last Post: 10-27-2016, 12:14 PM
  3. Replies: 1
    Last Post: 05-17-2013, 12:53 PM
  4. Replies: 2
    Last Post: 08-30-2012, 07:59 AM
  5. Update field in table after update on a subform
    By jpkeller55 in forum Queries
    Replies: 3
    Last Post: 09-30-2010, 08:02 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