open last data entry record for a specific person and a specific date. (1 Viewer)

Aryzona

Member
Local time
Today, 06:25
Joined
Nov 14, 2020
Messages
31
I have a form that multiple people use - i need to isolate them from each other, so DoCmd.GoToRecord =acLast is not an option because the last record may not have been their record....

if they open the form and begin entry and close the form .. then reopen the form to continue entry it creates a 2nd master record id for that person for that same date.
The form has a subform with detail records. I need for them to be able to continue adding the detail records without creating a second master record.

When they open the form, the first 2 fields are - their name (nameid) and Date (date()) - i would like to be able to query the table for an existing record for that person on that date and, if found, retrieve it so they can continue their entry of detail records attached to the previously created master.

can i do this OnLoad with a DLast expression ? or can i use a Select record where NameID = Name & Date = Date() on error New?

I don't know how to do what i need to do ... please Help.
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Today, 08:25
Joined
Feb 28, 2001
Messages
19,075
If you have a list of names that is suitable for use in a combo-box, Access has a combo-box wizard that comes into play where you can select one of the options, which is to select & display (make current) the record matching the combo box selection. If you did that, the wizard would build the code for you as a Click event for the combo. (Click event, because you select a particular combo row via a click). Once that VBA code is built, you could go back in to modify it to include finding either the most recent date or today's date, whichever is appropriate.
 

Aryzona

Member
Local time
Today, 06:25
Joined
Nov 14, 2020
Messages
31
If you have a list of names that is suitable for use in a combo-box, Access has a combo-box wizard that comes into play where you can select one of the options, which is to select & display (make current) the record matching the combo box selection. If you did that, the wizard would build the code for you as a Click event for the combo. (Click event, because you select a particular combo row via a click). Once that VBA code is built, you could go back in to modify it to include finding either the most recent date or today's date, whichever is appropriate.
Yes .. the name is selected by combo box drop down. and the date is set to date() since they do this work on a daily basis ... if they enter the form today it is because they are working it today.

I am unsure of how to access the Select & Display (make current). I have not seen this in my times creating combo boxes with the wizard....

What happens if the employee types the first few letters and chooses their name that way... there is no click event? would the name select & date work for OnDirty? The date fills in as soon as the form is open .. so OnDirty for Name would trigger when they selected their name whether they click or type correct?
 

bob fitz

AWF VIP
Local time
Today, 14:25
Joined
May 23, 2011
Messages
4,177
I believe the wizard creates a macro which can then be converted to code. It then puts the code in the After Update event of the combo box.
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Today, 08:25
Joined
Feb 28, 2001
Messages
19,075
Note that "OnDirty" is a form event, not a control event. Bob Fitz's suggestion for an After Update would work. Even a LOST FOCUS for the combo would work if you remembered the fact that at the time of the GOT FOCUS you didn't have a suggestion. See, for example, the .LISTINDEX property as a simple test for "no selection/have a selection" cases.
 

Aryzona

Member
Local time
Today, 06:25
Joined
Nov 14, 2020
Messages
31
ok .. the only place i can find OnCurrent is when i have the Form selected in the property sheet. When i have the combo box selected OnCurrent does not display anywhere in the property sheet.

I tried making a new combo box using the wizard and nowhere was i given an option for OnCurrent.

What am i missing ... is there a different wizard? for an existing combo box ?
 

bob fitz

AWF VIP
Local time
Today, 14:25
Joined
May 23, 2011
Messages
4,177
ok .. the only place i can find OnCurrent is when i have the Form selected in the property sheet. When i have the combo box selected OnCurrent does not display anywhere in the property sheet.

I tried making a new combo box using the wizard and nowhere was i given an option for OnCurrent.

What am i missing ... is there a different wizard? for an existing combo box ?
AFAIK a combo box does NOT have an OnCurrent event. Why are you even looking for one?
 

Aryzona

Member
Local time
Today, 06:25
Joined
Nov 14, 2020
Messages
31
1610504344234.png

This was why i thought i missed something in the Combo Box regarding OnCurrent. "select & display (make current) the record matching the combo...."

I am learning ... i don't know what i don't know!
 

Users who are viewing this thread

Top Bottom