Trying to set text box value within Form_Current()

binny45

New member
Local time
Today, 01:34
Joined
Jun 24, 2015
Messages
5
Alrighty, so I have a form where I select a "New" button and it provides a blank record for the user to fill out.

I'm trying to have it so the Item Code (think barcode) is automatically provided by taking the value from a query that only has one entry, the newly created max item code value, and set it as the value of the Item Code text box on the form.

I had originally thought that this occured on the onClick() of the New button, however as I traced the break points, the most recent records itemcode seemed to hang around until the end of the function. It was in the Form_Current() function that I was able to track it down to when it's tested to see if the record is blank, including the Itemcode number. So I now have a place in which to set the value of the text box, now it's just trying to find out how. :D

Me.ItemCode = ????

I've tried DBLookup but no joy. I've also tried creating a subform and referencing that but still no joy. This being said, I may have screwed both attempts up as I'm still new to vba, so I'm open to all suggestions and tutelage. I just want to set the ItemCode text box to the value of qry_MaxUniqueItemcode (name of query) with ItemcodeNumber (Field). There is only one value since I only requested the MAX() value of that column in my query.

I'm open to anything! I just want to get this done (and find the person that didn't implement proper autonumbering and incrementation at the beginning of this database!)
 
Refer to your query field and add the forms field to reference.
Example:
Myfield = [Forms]![frmsomeform]![somefield]
 
I've confirmed by hardcoding in a value to test the validity of the Me.ItemCode statement and it works. I literally just need to see how to reference the Access 2002 database. I always thought I could use [Queries]![QueryName]![FieldName] to reference that value, but it doesn't seem to work.
 
Can you show us a pic of what your trying to do?
Need more details.
 

Users who are viewing this thread

Back
Top Bottom