Repost-Pass 2 Fields to Another Form-Having Error Problems

M

Maurita

Hi All, hope someone can help with a problem that I can't figure out.
I previously posted this problem, but it was never resolved. I have
continued working on the problem, with no luck. I would appreciate
any help that would lead to a resolution to the following problem.

I am trying to pass two fields from PATIENT HISTORY-Form to
frmPersonalHabits. The main form is PATIENT HISTORY-Form which needs
to remain open so that the user can return after the frmPersonalHabits
is completed. I am using a command button named cmdReturnPHForm on
the frmPersonalHabits to return to the main form PATIENT HISTORY-
Form. I have researched this and other Google Access sites for help
but keep having problems, so I posted the other day and received help,
but the help did not resolve the problem, so I am reposting. I am
trying to pass the following by way of the click event of the command
button:

From: PATIENT HISTORY-Form DateSFESigned
Combo91 (includes PatientID)
To: frmPersonalHabits
PHDate copy of Combo91

Anyway, the last code I am using is as follows. I keep getting an
error stating that the "Switchboard can't find the frmPersonalHabits",
but this form is going through a command button on a form, not the
switchboard.

Forms![frmPersonalHabits]![PHDate] = Forms![PATIENT HISTORY-Form]!
[DateSFESigned]
Forms![frmPersonalHabits]![Combo91] = Forms![PATIENT HISTORY-Form]!
[Combo91]
Refresh

P.S.- I tried changing the form name PATIENT HISTORY-Form to
frmPatientHistory but then I received errors stating that the form
name was not recognized.

I really appreciate any help that can be given. I've spent over a
week working on this problem and am ready to pull my hair out. This
is a project for a volunteer organization for which I am not getting
any compensation, so I need to get it done as soon as I can because
it's putting me behind other projects.

Thanks.

Maurita Searcy
 
T

tina

your post isn't really very clear, hon. please give us the following:

- the names of both forms *as they show in the database window*.
- state which form the command button is on.
- are there any subforms on either form? if yes, are the date (textbox)
controls and the combo box controls on the main form(s) or the subform(s) -
*be specific* as to the location of each of the four controls.
- copy/paste the *complete* event procedure attached to the command button.

hth
 
M

Maurita

your post isn't really very clear, hon. please give us the following:

- the names of both forms *as they show in the database window*.
- state which form the command button is on.
- are there any subforms on either form? if yes, are the date (textbox)
controls and the combo box controls on the main form(s) or the subform(s) -
*be specific* as to the location of each of the four controls.
- copy/paste the *complete* event procedure attached to the command button.

hth

TINA,

Thank you for your assistance. I will try to answer your questions
below. I am so very sorry for the confusion in my earlier post. I
tried to be clear, but rereading the post, I can see where quite a few
questions came up.

I am working with a main form titled frmPatientHistory. From this
form, when the command button cmdPersonalHabits is clicked, the
frmPersonalHabits pops up with two fields needing to be filled in from
the main form. When I get this problem resolved, I have other forms
that I need to do the same thing too that are referenced from the main
form frmPatientHistory, but for now, I am only concentrating on
frmPersonalHabits. The forms and fields that reference one another
are outlined below:

frmPatientHistory
DateSFESigned Combo91
cmdPersonalHabits
frmPersonalHabits
PHDate Combo91

Since Combo91 holds various information on frmPatientHistory, I have
copied the combo box from this form onto frmPersonalHabits so that the
information transfers and I can create textboxes to show combo box
information (ex. SS#, DOB, First and Last Name, PatientID.

By the way, the PatientID field links each of the tables the forms are
built on.

There are no subforms.

I reworked my code from the earlier post and I think it works better
except for a compile error I'm receiving on frmPersonalHabits (details
below). I sure appreciate all your help. I'm at a loss as to what to
do next.

CODE: frmPatientHistory (Main Form) Command button Click Event
procedure. This form comes up fine with the following code:

strOpenArgs = "DateSFESigned=" & DateSFESigned & ";Combo91=" &
Combo91
DoCmd.OpenForm "frmPersonalHabits", OpenArgs:=strOpenArgs

CODE: frmPersonalHabits Open Event code. (I receive a compile error:
Next without For) With the error in this code, the form will no
longer pop up when the cmdPatientHistory command button is clicked on
the frmPatientHistory

Dim intLoop As Integer
Dim varOptions As Variant
Dim varValue As Variant
If IsNull(Me.OpenArgs) = False Then
varOptions = Split(Me.OpenArgs, ";")
For intLoop = LBound(varOptions) To UBound(varOptions)
varValue = Split(varOptions(intLoop), "=")
If UBound(varValue) > 0 Then
Select Case varValue(0)
Case "DateSFESigned"
DateSFESigned = varValue(1)
Case "Combo91"
Combo91 = varValue(1)
End Select
If UBound(varValue) > 0 Then
Next intLoop
End If

End Sub


Thank you so very much for all your help. I think I am almost there,
but not enough to make the code work.

Maurita
 
T

tina

try

Dim intLoop As Integer
Dim varOptions As Variant
Dim varValue As Variant
If IsNull(Me.OpenArgs) = False Then
varOptions = Split(Me.OpenArgs, ";")
For intLoop = LBound(varOptions) To UBound(varOptions)
varValue = Split(varOptions(intLoop), "=")
If UBound(varValue) > 0 Then
Select Case varValue(0)
Case "DateSFESigned"
DateSFESigned = varValue(1)
Case "Combo91"
Combo91 = varValue(1)
End Select
End If
Next intLoop
End If

though, since you say that frmPatientHistory remains open, it might be
easier to simply reference the form/control values directly, rather than
passing them in the OpenArgs, as

Private Sub Form_Load()

Dim frm as Form

Set frm = Forms!frmPatientHistory

Me!DateSFESigned = frm!DateSFESigned
Me!Combo91 = frm!Combo91

End Sub

i did note the "Switchboard" error message you reported in your first post
in this thread; are you using A2000 or newer? if so, have you turned *off*
the Name Autocorrect option (found under Tools | Options | General tab on
the database menu bar)? if the option is on, recommend you do the following:

create a new, blank database and immediately turn OFF Name Autocorrect, then
compact the database. import all the objects from your working database into
the new one, and then compact again. for more information on Name
"Autocorrupt", as it's un-affectionately known, see
http://home.att.net/~california.db/tips.html#aTip3.

hth
 
M

Maurita

try

Dim intLoop As Integer
Dim varOptions As Variant
Dim varValue As Variant
    If IsNull(Me.OpenArgs) = False Then
        varOptions = Split(Me.OpenArgs, ";")
        For intLoop = LBound(varOptions) To UBound(varOptions)
            varValue = Split(varOptions(intLoop), "=")
            If UBound(varValue) > 0 Then
                Select Case varValue(0)
                    Case "DateSFESigned"
                        DateSFESigned = varValue(1)
                    Case "Combo91"
                        Combo91 = varValue(1)
                End Select
            End If
        Next intLoop
    End If

though, since you say that frmPatientHistory remains open, it might be
easier to simply reference the form/control values directly, rather than
passing them in the OpenArgs, as

Private Sub Form_Load()

    Dim frm as Form

    Set frm = Forms!frmPatientHistory

    Me!DateSFESigned = frm!DateSFESigned
    Me!Combo91 = frm!Combo91

End Sub

i did note the "Switchboard" error message you reported in your first post
in this thread; are you using A2000 or newer? if so, have you turned *off*
the Name Autocorrect option (found under Tools | Options | General tab on
the database menu bar)? if the option is on, recommend you do the following:

create a new, blank database and immediately turn OFF Name Autocorrect, then
compact the database. import all the objects from your working database into
the new one, and then compact again. for more information on Name
"Autocorrupt", as it's un-affectionately known, seehttp://home.att.net/~california.db/tips.html#aTip3.

hth




button.















- Show quoted text -

TINA,

Thank you so much for your help. I never heard of Autocorrect, but
will sure be aware of it in the future, thanks. I did as you
suggested by Autocorrect, creating a new database, turning off
Autocorrect again, compacting, and then importing everything from the
database with the error.

Unfortunately, I now have one problem with a line of code, Combo91 =
varValue(1). I get the error "Can't Asssign a Value to this Object".

Thank you Tina for any ideas regarding this error.

Maurita
 
T

tina

first, try compiling your code (in the VB Editor window, click Debug |
Compile... from the menu bar). you'll need to fix any errors that prevent a
compile. then try typing

me!combo91=0

in the procedure. does Access automatically change the capitalization to

Me!Combo91

when you move to the next line in the procedure? if not, then the name of
the control is *not* Combo91 - at least, Access doesn't recognize it. also,
make sure that the data type of the value in varValue(1) is the same as the
data type in the *bound column* of the combo box control.

hth


try

Dim intLoop As Integer
Dim varOptions As Variant
Dim varValue As Variant
If IsNull(Me.OpenArgs) = False Then
varOptions = Split(Me.OpenArgs, ";")
For intLoop = LBound(varOptions) To UBound(varOptions)
varValue = Split(varOptions(intLoop), "=")
If UBound(varValue) > 0 Then
Select Case varValue(0)
Case "DateSFESigned"
DateSFESigned = varValue(1)
Case "Combo91"
Combo91 = varValue(1)
End Select
End If
Next intLoop
End If

though, since you say that frmPatientHistory remains open, it might be
easier to simply reference the form/control values directly, rather than
passing them in the OpenArgs, as

Private Sub Form_Load()

Dim frm as Form

Set frm = Forms!frmPatientHistory

Me!DateSFESigned = frm!DateSFESigned
Me!Combo91 = frm!Combo91

End Sub

i did note the "Switchboard" error message you reported in your first post
in this thread; are you using A2000 or newer? if so, have you turned *off*
the Name Autocorrect option (found under Tools | Options | General tab on
the database menu bar)? if the option is on, recommend you do the following:

create a new, blank database and immediately turn OFF Name Autocorrect, then
compact the database. import all the objects from your working database into
the new one, and then compact again. for more information on Name
"Autocorrupt", as it's un-affectionately known, seehttp://home.att.net/~california.db/tips.html#aTip3.

hth




button.















- Show quoted text -

TINA,

Thank you so much for your help. I never heard of Autocorrect, but
will sure be aware of it in the future, thanks. I did as you
suggested by Autocorrect, creating a new database, turning off
Autocorrect again, compacting, and then importing everything from the
database with the error.

Unfortunately, I now have one problem with a line of code, Combo91 =
varValue(1). I get the error "Can't Asssign a Value to this Object".

Thank you Tina for any ideas regarding this error.

Maurita
 

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