Take ID from SubForm

Marinus

I'm learning... :)
Local time
Today, 18:08
Joined
Jun 16, 2010
Messages
140
Hi All,
Trying to take the last ID on a SubForm and make it appear in a unbound textbox SubFormID.. This without typing it there.. :D
e.g; on screenshot, the last ID on the SubForm is 134 and I would like to get that in the textbox. Any help appreciated..
 

Attachments

  • SubFormID.jpg
    SubFormID.jpg
    63.1 KB · Views: 151
Look into DMax()

That did the trick,

Code:
=DMax("ID","Qry_sf_Buy")

However, if I make a new textbox and use

Code:
=DMax("ID","Qry_sf_Sell")

The record show 9 and the text box shows number 172..
When I look at the ID's of tblDocketSell #10 is the highest number??

Strange...
 
Remember the WHERE argument of the DMax() to streamline the result to that particular ID that links the subform to the main form?

=DMax("field", "source", "id = " & [ID field])
 
Hi vbaInet, the Where argument didn't do anything different, adding the ID to the SubForm fmrQry_sf_Sell did. After a nap on the couch I noticed that The SubForm didn't have the ID field on it and it assumed automatically that it had to take the ID from the tblDocket. Since my form frm_sf_Buy did have the ID, this showed the correct ID. After adding the ID to the frm_sf_Sell, now both txtboxes show the correct ID. Great Job, You really put me right and made me think and learn.. As did many others here on the board.. :D
 

Users who are viewing this thread

Back
Top Bottom