Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Form and Subform Fun!??? Help! :o)

Status
Not open for further replies.

dlgtwice

Programmer
Aug 19, 2003
17
US
I've spent 4 days trying to find a work around this problem.

I have 2 subforms and 1 main form. In one subform I have a calendar control and a text field named "CurrentDate". In the other subform I have a query with three fields to display a persons scheduled vacation days by date, hours and temporary holding hours.

I implemented the code below to set the CurrentDate field to match the individual dates of each row in the query because I have some logic that checks to see what other time is available on the vacation calendar.

Private Sub Hours_GotFocus()
h = [Hours]
Forms![frmPTOScheduler-Overview]![sfrmPTOScheduler_ScheduledTime].Form![tbHoldingHours].Value = h
d = Date
Forms![frmPTOScheduler-Overview]![sfrmPTOScheduler_BusinessSchedule2].Form![CurrentDate].Value = d
End Sub

This part of it works great. My problem comes in when I try to use the calendar control on my first subform. It still works and changes the date in CurrentDate field like it is suppose to;however, when I try to add a vacation selection which is a field located on my main form the Current date reverts back to the date in my second subform.

I've tried using SetFocus, Refresh and Requery in different combinations to clear the CurrentDate field of that variable selection but it still keeps changing back to the last date in the 2nd subform.

Help! Any ideas would be greatly appreciated!

Dan G [bigears]



 
Hi

Not sure that I understand your explanation, but I think the problem is that you have the code in the got focus event, should it not be in the oncurrent event of the sub form?

Regards

Ken Reay
Freelance Solutions Developer
Boldon Information Systems Ltd
Website needs upgrading, but for now - UK
 
Thanks for responding KenReay. I don't see an oncurrent event in either the hours field or the subform properties window. Do you know, is that an event available in Access 2000?

Thanks

Dan G [ponder]
 
Hi

You need to look in the form, not the subform control. The subform control is a container which contains a (sub) form. A sub form is in fact just a form which happens to be held in a subform container. So in short, open the (sub) form in design view, in the properties window scroll down to events and look for the OnCurrent event, it will be there I assure you

Regards

Ken Reay
Freelance Solutions Developer
Boldon Information Systems Ltd
Website needs upgrading, but for now - UK
 
Hmmm? I found the oncurrent event and placed the code in it. However, I'm still having the same problem.

I use the refresh command on my main form to cause a field "ScheduleNewHours" to set it's date value with the default property with the value of the "CurrentDate" field from my calendar subform. Before I run the code we are discussing above it works fine. It's only after I enter the subform and only if I click the hours field but don't actually change the value of the field that value is stuck. If I tab out of the hours field and then use the calendar control the main form works fine again.

Thanks

Dan G [3eyes]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top