I am trying to get this piece of code to work. I want to double click a name
in a subform and have the record in another form open. tblContributors.
[ContributorID] is the name of the hidden primary key field of the table that
holds the data for the form I want to open. So I make a function named
ViewDonor and then call it in Sub txtDonorLastName_DblClick. I thought that
the DoCmd.OpenForm should work. Obviously I am wrong. I get an error that
says "variable not defined" and it highlights the second tblContributors.
Anyone know what I am doing wrong? Anyone but me not know what I am doing
wrong?
Thanks,
Scott
Option Compare Database
Option Explicit
--------------------------------------------------
Private Sub ViewDonor()
On Error GoTo Err_ViewDonor
DoCmd.OpenForm "frmViewDonor", , , "tblContributors.[ContributorID]=" &
tblContributors.ContributorID
Exit_ViewDonor:
Exit Sub
Err_ViewDonor:
MsgBox Err.Description
Resume Exit_ViewDonor
End Sub
---------------------------------------------------
Private Sub txtDonorLastName_DblClick(Cancel As Integer)
ViewDonor
End Sub
--
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/Forums.aspx/access-forms/200911/1
MS Access doesn't know what tblContributors is in that context - it is
trying to find a control or variable with that name, and it can't, hence the
error.
ContributorID must be in a control on the record (i.e. on the form) you are
double-clicking, though it can be hidden. Then, your criteria in the DoCmd.
OpenForm statement must reference that control, something like this:
DoCmd.OpenForm "frmViewDonor", , , "tblContributors.[ContributorID]=" & Forms!
Myform.ContributorID
or
DoCmd.OpenForm "frmViewDonor", , , "tblContributors.[ContributorID]=" & Me!
ContributorID
This assumes that the control name is ContributorID.
HTH
John
--
John Goddard
Ottawa, ON Canada
jrgoddard at cyberus dot ca
"Find a job that you love... and you'll never work a day in your life."
"Scott_Brasted via AccessMonster.com" <u56211@uwe> wrote in message
news:9fa79a2172613@uwe...
Happy Thanksgiving.
Scott
J_Goddard wrote:
>Hi -
>
>MS Access doesn't know what tblContributors is in that context - it is
>trying to find a control or variable with that name, and it can't, hence the
>error.
>
>ContributorID must be in a control on the record (i.e. on the form) you are
>double-clicking, though it can be hidden. Then, your criteria in the DoCmd.
>OpenForm statement must reference that control, something like this:
>
>DoCmd.OpenForm "frmViewDonor", , , "tblContributors.[ContributorID]=" & Forms!
>Myform.ContributorID
>
>or
>
>DoCmd.OpenForm "frmViewDonor", , , "tblContributors.[ContributorID]=" & Me!
>ContributorID
>
>This assumes that the control name is ContributorID.
>
>HTH
>
>John
>
>>Greetings,
>>
>[quoted text clipped - 32 lines]
>> ViewDonor
>>End Sub
>
--
Everything worked great until I changed the subform from a datasheet to a
continuous form. Now the first line works, but every line after that opens a
blank form (no detail section - formheader and form footer are there). Can I
not use a continuous form or do I need to change something?
Thanks,
Scott
J_Goddard wrote:
>Hi -
>
>MS Access doesn't know what tblContributors is in that context - it is
>trying to find a control or variable with that name, and it can't, hence the
>error.
>
>ContributorID must be in a control on the record (i.e. on the form) you are
>double-clicking, though it can be hidden. Then, your criteria in the DoCmd.
>OpenForm statement must reference that control, something like this:
>
>DoCmd.OpenForm "frmViewDonor", , , "tblContributors.[ContributorID]=" & Forms!
>Myform.ContributorID
>
>or
>
>DoCmd.OpenForm "frmViewDonor", , , "tblContributors.[ContributorID]=" & Me!
>ContributorID
>
>This assumes that the control name is ContributorID.
>
>HTH
>
>John
>
>>Greetings,
>>
>[quoted text clipped - 32 lines]
>> ViewDonor
>>End Sub
>
--
If the above is OK, try putting a Msgbox call in the Double-click code just
before it opens the Contributor form, to verify what ContributorID is:
MsgBox "Contributor ID = " & me!ContributorID
docmd.openform.....
John
Scott_Brasted wrote:
>Hi again,
>
>Everything worked great until I changed the subform from a datasheet to a
>continuous form. Now the first line works, but every line after that opens a
>blank form (no detail section - formheader and form footer are there). Can I
>not use a continuous form or do I need to change something?
>
>Thanks,
>Scott
>
>>Hi -
>>
>[quoted text clipped - 25 lines]
>>> ViewDonor
>>>End Sub
--
John Goddard
E-Mail: jrgoddard AT cyberus DOT ca
Message posted via http://www.accessmonster.com
Here is what I have right now:
Any thoughts?
Best,Scott
Option Compare Database
Option Explicit
-----------------------
Private Sub ViewDonor()
On Error GoTo Err_ViewDonor
MsgBox "Contributor ID = " & Me!idContributorID
DoCmd.OpenForm "frmViewDonor", , , "[ContributorID] = " & Me.
idContributorID
Exit_ViewDonor:
Exit Sub
Err_ViewDonor:
MsgBox Err.Description
Resume Exit_ViewDonor
End Sub
----------------------------
Private Sub txtName_DblClick(Cancel As Integer)
ViewDonor
End Sub
Al Campagna wrote:
>Scott,
> If ContributerID is numeric, try...
>DoCmd.OpenForm "frmViewDonor", , , "[ContributorID] = " & Me.ContributorID
>> Greetings,
>>
>[quoted text clipped - 35 lines]
>> ViewDonor
>> End Sub
--
Message posted via http://www.accessmonster.com
Do the ContributorID values displayed by the Message Box appear to be correct?
If they are, then that suggests that the problem is not with the form you are
double-clicking in, but there is a problem with frmViewDonor, or with the
query behind that form. For example - does the query behind frmViewDonor
have criteria in it? Is the data in the ContributorID field of that query
what you expect it to be? Is there any code in frmViewDonor that might affect
what records are seen?
These are the first places I would look for errors.
John
>>Scott,
>> If ContributerID is numeric, try...
>[quoted text clipped - 4 lines]
>>> ViewDonor
>>> End Sub
--
John Goddard
Ottawa, ON Canada
jrgoddard at cyberus dot ca
Message posted via http://www.accessmonster.com
I put code for opening form WITHOUT CRITERIA back in. Worked fine. Put
criteria back in and got error that vb could not find the form referenced in
the code.
This all worked originally when subform was datasheet. Then changed form to
continuous for formatting purposes. Stopped working. Changed form back and it
went to hell.
All names are correct as far as I can tell. Here is what I have now:
Option Compare Database
Option Explicit
-----------------------
Private Sub ViewDonor()
On Error GoTo Err_ViewDonor
DoCmd.OpenForm "frmViewDonor", , , "tblContributors.[ContributorID]=" &
Forms!frmCampaignPledgeListingSubform.idContributorID
Exit_ViewDonor:
Exit Sub
Err_ViewDonor:
MsgBox Err.Description
Resume Exit_ViewDonor
End Sub
-----------------------
Private Sub Name_DblClick(Cancel As Integer)
ViewDonor
End Sub
Thanks again,
Scott
J_Goddard wrote:
>Hi -
>
>Do the ContributorID values displayed by the Message Box appear to be correct?
>If they are, then that suggests that the problem is not with the form you are
>double-clicking in, but there is a problem with frmViewDonor, or with the
>query behind that form. For example - does the query behind frmViewDonor
>have criteria in it? Is the data in the ContributorID field of that query
>what you expect it to be? Is there any code in frmViewDonor that might affect
>what records are seen?
>
>These are the first places I would look for errors.
>
>John
>
>>Hello,
>>Sorry, that did not work. No errors and it compiled, but I get a blank detail
>[quoted text clipped - 31 lines]
>>>> ViewDonor
>>>> End Sub
>
--
We are obviously missing something. I wish I could be more help - maybe
someone else has some ideas?
John
>>Hi -
>>
>[quoted text clipped - 15 lines]
>>>>> ViewDonor
>>>>> End Sub
--
John Goddard
Ottawa, ON Canada
jrgoddard at cyberus dot ca
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/Forums.aspx/access-forms/200911/1