Repost - Using 1 form dbl click event

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I think I should explain this better....

I want to use one form 'frmAssignTime' to enter information in a text box
such as [0830] on the form 'frmSchedule' by using the dbl click event of a
text box [0830LastName].

The form 'frmSchedule' has a hidden text box for each 30 minute time slot,
hence 0830, 0900, 0930 and so on.

Double clicking on the text box [0830LastName] opens the form
'frmAssignTime'.

The form 'frmAssignTime' allows the user to select a patient name and click
on a button to assign that patient's PatientID value to the [0830] text box
on the 'frmSchedule'. Then the [0830LastName] looks up the patients last name
and displays it.

I want to use the same form for all the [0830LastName], [0900LastName] etc..
text boxes double click event. so I need to pass a string to the form
'frmAssignTime' that contains the field name of the hidden text box [0830],
[0900] etc...

I've tried :

Dim TimeSlot as String
TimeSlot = "Forms!frmSchedule." & strTimeSlot
TimeSlot = Forms!frmSelectPatient.[PatientID]

etc...

I tried passing the 'strTimeSlot' string as an argument, but when I step
through the code, the value for TimeSlot is just 'Forms!frmSchedule.' and it
shows strTimeSlot as empty.

So by now it's probably obvious to you what I am missing, but I can't seem
to figure it out.

Thanks again for any help.....
 
Paul said:
I think I should explain this better....

I want to use one form 'frmAssignTime' to enter information in a text box
such as [0830] on the form 'frmSchedule' by using the dbl click event of a
text box [0830LastName].

The form 'frmSchedule' has a hidden text box for each 30 minute time slot,
hence 0830, 0900, 0930 and so on.

Double clicking on the text box [0830LastName] opens the form
'frmAssignTime'.

The form 'frmAssignTime' allows the user to select a patient name and click
on a button to assign that patient's PatientID value to the [0830] text box
on the 'frmSchedule'. Then the [0830LastName] looks up the patients last name
and displays it.

I want to use the same form for all the [0830LastName], [0900LastName] etc..
text boxes double click event. so I need to pass a string to the form
'frmAssignTime' that contains the field name of the hidden text box [0830],
[0900] etc...

I've tried :

Dim TimeSlot as String
TimeSlot = "Forms!frmSchedule." & strTimeSlot
TimeSlot = Forms!frmSelectPatient.[PatientID]

etc...

I tried passing the 'strTimeSlot' string as an argument, but when I step
through the code, the value for TimeSlot is just 'Forms!frmSchedule.' and it
shows strTimeSlot as empty.

So by now it's probably obvious to you what I am missing, but I can't seem
to figure it out.


Create a Access.Textbox variable in frmAssignTime.
In the DblClick events of the frmSchedule textbox's set that variable to
the appropriate hidden textbox.
In the click event of the frmAssignTime button set the value of the
textbox variable to the PatienID.

For instance in the frmSchedule module:

Private Sub 0830LastName_DblClick(Cancel As Integer)
Call OpenAssignTime(Me.0830)
End Sub

Private Sub OpenAssignTime(tb As Access.TextBox)
Dim f As Access.Form
DoCmd.OpenForm "frmAssignTime", acNormal
Set f = Forms("frmAssignTime")
Set f.Target = tb
Set f = Nothing
End Sub

In the frmAssignTime module:

Private m_target As Access.TextBox

Public Property Set Target(tb As Access.TextBox)
Set m_target = tb
End Property

Private Sub btnAssignID_Click()
m_target.value = Me.PatientID
Set m_target = Nothing
DoCmd.Close
End Sub
 
Back
Top