Results 1 to 4 of 4
  1. #1
    jker is offline Advanced Beginner
    Windows 10 Access 2007
    Join Date
    Aug 2023
    Posts
    36

    Save a colum into a variable fro a form

    I have a form that has a button the gets fired during an ON_CLICK event,

    I want to do a SELECT of a table and get the MIN CUSTOMER_ID and store that value into a TXT field that appears on my form


    What is happening is that my SQL is creating a table containing the MIN value.... this is not what i want

    I want to save the MIN value into a TXT field on my form:

    see the attached screen imagesClick image for larger version. 

Name:	form.JPG 
Views:	14 
Size:	178.4 KB 
ID:	50952Click image for larger version. 

Name:	Capture.JPG 
Views:	14 
Size:	14.4 KB 
ID:	50953Click image for larger version. 

Name:	Capture2.JPG 
Views:	14 
Size:	23.8 KB 
ID:	50954

    Can someone tell me the correct syntax of my SELECT statement?

  2. #2
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,940
    I would use DMin()
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  3. #3
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,525
    the select sql will do nothing.
    make a query the opens a datasheet to view the select
    Qry1 = select * from table where [field]=forms!fMyForm!txtbox

    to view the 'select' qry:
    docmd.openquery "Qry1"

  4. #4
    jker is offline Advanced Beginner
    Windows 10 Access 2007
    Join Date
    Aug 2023
    Posts
    36
    excellent idea!!!!!! I tried it and it gave me exactly what i needed

    here is the solution: =DMin("TREATL5_KEY","TREATMENT_LAST5","TREATL5_CUS TOMER_ID=" & "TXTCUSTOMERID")

    psuedo code" get the minimum value of TREATL5_KEY from table TREATMENT_LAST5 where the customer id in the table = the value of TXTCUSTOMERID

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

Similar Threads

  1. Save single field in variable
    By cybermonkey in forum Programming
    Replies: 2
    Last Post: 04-06-2021, 08:31 AM
  2. Replies: 7
    Last Post: 05-31-2012, 02:25 PM
  3. Sum Negative Numbers In Colum
    By geraldselectric in forum Access
    Replies: 1
    Last Post: 01-16-2012, 03:42 PM
  4. Refering to variable form names inside a variable
    By redpetfran in forum Programming
    Replies: 2
    Last Post: 05-21-2010, 01:39 PM
  5. Row and colum color editing
    By jerald in forum Database Design
    Replies: 0
    Last Post: 03-18-2009, 05: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