Results 1 to 2 of 2
  1. #1
    calgarianguy is offline Novice
    Windows Vista Access 2003
    Join Date
    Jun 2013
    Posts
    1

    Post Passing Form Field Value to Query

    Good Day Everyone,

    Just wondering if I can get some help you one of the Access Guru for my Access problem.

    I am trying to group by my query based on supplier's name and retrive the last serial number of the backcharge and add 1 into that for the next one.

    Record would be sort like below:

    Servial # Supplier Name
    1 AB
    2 AB
    3 AB
    1 CD
    2 CD
    1 EF
    2 EF
    3 EF
    4 EF

    On the form if Supplier AB is focus in down down box I want to get 4 in next serial number field?

    Please advise how to achieve above result.

    -------------
    Following are some of my thought that I tried and did not work

    Query:
    SELECT Count(FinalBackchargeLog.FSupToBeChargedNumber) AS MaxOfFSupToBeChargedNumber
    FROM FinalBackchargeLog
    GROUP BY FinalBackchargeLog.FSupplierToBeCharged


    HAVING (((FinalBackchargeLog.FSupplierToBeCharged)=Forms![Add New Backcharge]!txtFSupplierToBeCharged));

    On Event:
    Dim loc As String
    Me.txtSerialNo.SetFocus
    loc = DLookup("MaxOfFSupToBeChargedNumber", "BackchargeLogSerialNumber_Q")
    Me.txtSerialNo.Value = loc + 1

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,598
    What is purpose of query? Do you want to build a report? What is purpose of the serial number?

    Textbox in report has a RunningSum property that will allow dynamic generation of the serial number. It won't be saved in table but the record on report will display the value.

    Otherwise, saving calculated data (data dependent on other data) can be tricky, as you are discovering. Why doesn't it work - error message, wrong results, nothing happens?

    Probably don't need the query. Try DMax. Assuming FSupplierToBeCharged is number type.

    If IsNull(Me!loc) Then Me!loc = Nz(DMax("FSupToBeChargedNumber", "FinalBackchargeLog", "FSupplierToBeCharged)=" & Me.txtFSupplierToBeCharged),0) + 1
    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.

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

Similar Threads

  1. passing values from form to query
    By gregd in forum Access
    Replies: 6
    Last Post: 05-02-2013, 03:18 PM
  2. Replies: 9
    Last Post: 05-30-2012, 12:57 AM
  3. Replies: 3
    Last Post: 05-09-2012, 04:04 PM
  4. Passing Form Variable to Query
    By allenrickson in forum Reports
    Replies: 10
    Last Post: 06-27-2011, 07:33 PM
  5. Form not passing data to query
    By bobfin in forum Queries
    Replies: 13
    Last Post: 08-11-2010, 05:28 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