Repost - Still having trouble with code

G

Guest

My orginal post is below, and a response I received is below that. The
problem is I am missing something. I have been working on this for a week now
and I do not understand what I am doing in part.

***Orignal post***

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...


***Reply to my post, code only***

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 ***This part I am not sure about***

Public Property Set Target(tb As Access.TextBox) ***This and the line
above***
Set m_target = tb ***I've put in a Module***
End Property

Private Sub btnAssignID_Click() ***This is in the form's Assign Button***
m_target.value = Me.PatientID
Set m_target = Nothing
DoCmd.Close
End Sub



I am fairly sure I have not put something in the right place. I get an error
that states Object Required when I try clicking on the button.

Can someone help me to understand this.

Cheers
 
S

Steve

Paul,

Email me your email address at my email address below and I wil send you a
screen shot of a patient scheduling module I could implement for you that
looks just like what you would see in a doctor's office.
 
J

John Nurick

Hi Paul,

If I understand the situation right, I'd pass the name of the control in
OpenArgs when opening the form. And I'd never give controls (or fields)
names like 0830, there's far too much scope for confusion: instead, use
txt0830 for textbox names, and perhaps f0830 or fld0830 for field names.

So your all your double-click events would contain something like this:

DoCmd.OpenForm "frmAssignTime", acNormal,,,, _
acDialog, Me.ActiveControl.Name 'this Me refers to frmSchedule

And then when you need it (e.g. in the Click event of frmAssignTime's OK
button) you can get the name with

Dim strControlToUpdate As String
strControlToUpdate = Me.OpenArgs 'this Me refers to frmAssignTime

or assign a value to the textbox with

Forms("frmSchedule").Controls(strControlToUpdate).Value = something


My orginal post is below, and a response I received is below that. The
problem is I am missing something. I have been working on this for a week now
and I do not understand what I am doing in part.

***Orignal post***

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...


***Reply to my post, code only***

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 ***This part I am not sure about***

Public Property Set Target(tb As Access.TextBox) ***This and the line
above***
Set m_target = tb ***I've put in a Module***
End Property

Private Sub btnAssignID_Click() ***This is in the form's Assign Button***
m_target.value = Me.PatientID
Set m_target = Nothing
DoCmd.Close
End Sub



I am fairly sure I have not put something in the right place. I get an error
that states Object Required when I try clicking on the button.

Can someone help me to understand this.

Cheers
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top