How to pass contact id to a newly opened form?

B

Bob

Hi folks,

I have a command button on one of my forms which I use to open a second
form (frmSameAs) in popup mode.

frmSameAs has a combobox on it which I use to list of the contacts in
my database. I want the listing to exclude the current contact.

At the moment, the rowsource for the combo box points to a query
(qryAllOtherContacts). qryAllOtherContacts requires a value for the
current ContactID shown in my existing form (with the command button on
it).

I can open frmSameAs without a problem. But when I press the combo box
to get the drop down list it opens a dialog/parameter box asking for
Me.ContactID.

Is there a way that I can pass the ContactID in my existing form direct
to frmSameAs to provide required parameter for the query
programmatically?

I've tried setting the rowsource for frmSaveAs to "qryAllOtherContacts
WHERE ContactID<>" & Me.ContactID. But this doesn't work.



TIA
Bob
 
J

J. Goddard

Hi -

What is the recordsource for the combo/dialog box on frmSameAs? If it
refers to me!ContactID, it thinks that is a field on frmSaveAs.

You could change the combo box control source in the On Open event of
frmSaveAs:

[combobox].controlsource="Select [whatever] from [contacts] where
contactID <> '" & forms![main form]![contactID] & "'"

but that only works if you are only calling frmSameAs from the one form

Could you not just put that combo box on the main form, rather than
using a separate popup form?


Hope this helps (a bit, anyway)

John
 
B

Bob

Thanks for the response John.

The combo box is currently unbound. For this reason, I've tried
fiddling with the Open event to try and change the rowsource as opposed
to the recordsource.

The reason I have the combo box on a new form is that my existing form
is getting a little overcrowded with controls as it is. There simply
isn't enough space left to fit another combo box! :)


Regards
Bob


J. Goddard said:
Hi -

What is the recordsource for the combo/dialog box on frmSameAs? If it
refers to me!ContactID, it thinks that is a field on frmSaveAs.

You could change the combo box control source in the On Open event of
frmSaveAs:

[combobox].controlsource="Select [whatever] from [contacts] where
contactID <> '" & forms![main form]![contactID] & "'"

but that only works if you are only calling frmSameAs from the one form

Could you not just put that combo box on the main form, rather than
using a separate popup form?


Hope this helps (a bit, anyway)

John

Hi folks,

I have a command button on one of my forms which I use to open a second
form (frmSameAs) in popup mode.

frmSameAs has a combobox on it which I use to list of the contacts in
my database. I want the listing to exclude the current contact.

At the moment, the rowsource for the combo box points to a query
(qryAllOtherContacts). qryAllOtherContacts requires a value for the
current ContactID shown in my existing form (with the command button on
it).

I can open frmSameAs without a problem. But when I press the combo box
to get the drop down list it opens a dialog/parameter box asking for
Me.ContactID.

Is there a way that I can pass the ContactID in my existing form direct
to frmSameAs to provide required parameter for the query
programmatically?

I've tried setting the rowsource for frmSaveAs to "qryAllOtherContacts
WHERE ContactID<>" & Me.ContactID. But this doesn't work.



TIA
Bob
 
J

J. Goddard

An overcrowded form - have you checked out the Tab control? This *very*
useful control allows you to a) put a lot more controls on to a single
form, and b) group related controls together so users see only a few at
a time. Items common to the whole form can be outside the tab control.

John

Thanks for the response John.

The combo box is currently unbound. For this reason, I've tried
fiddling with the Open event to try and change the rowsource as opposed
to the recordsource.

The reason I have the combo box on a new form is that my existing form
is getting a little overcrowded with controls as it is. There simply
isn't enough space left to fit another combo box! :)


Regards
Bob


J. Goddard wrote:

Hi -

What is the recordsource for the combo/dialog box on frmSameAs? If it
refers to me!ContactID, it thinks that is a field on frmSaveAs.

You could change the combo box control source in the On Open event of
frmSaveAs:

[combobox].controlsource="Select [whatever] from [contacts] where
contactID <> '" & forms![main form]![contactID] & "'"

but that only works if you are only calling frmSameAs from the one form

Could you not just put that combo box on the main form, rather than
using a separate popup form?


Hope this helps (a bit, anyway)

John

Hi folks,

I have a command button on one of my forms which I use to open a second
form (frmSameAs) in popup mode.

frmSameAs has a combobox on it which I use to list of the contacts in
my database. I want the listing to exclude the current contact.

At the moment, the rowsource for the combo box points to a query
(qryAllOtherContacts). qryAllOtherContacts requires a value for the
current ContactID shown in my existing form (with the command button on
it).

I can open frmSameAs without a problem. But when I press the combo box
to get the drop down list it opens a dialog/parameter box asking for
Me.ContactID.

Is there a way that I can pass the ContactID in my existing form direct
to frmSameAs to provide required parameter for the query
programmatically?

I've tried setting the rowsource for frmSaveAs to "qryAllOtherContacts
WHERE ContactID<>" & Me.ContactID. But this doesn't work.



TIA
Bob
 
B

Bob

Hi John,

I prefer to have everything visible at once rather than have the user
tab to different pages. Its just a preference thing.

By the way, I managed to resolve my problem by passing the ContactID as
an OpenArg and then simply changing my query to point to the form's
OpenArgs rather than to Me.ContactID itself. I almost had it in the
first place - at one stage I had my query pointing to Me.OpenArgs
(instead of just OpenArgs).

Hopefully this post helps someone else out there.


Regards
Bob


J. Goddard said:
An overcrowded form - have you checked out the Tab control? This *very*
useful control allows you to a) put a lot more controls on to a single
form, and b) group related controls together so users see only a few at
a time. Items common to the whole form can be outside the tab control.

John

Thanks for the response John.

The combo box is currently unbound. For this reason, I've tried
fiddling with the Open event to try and change the rowsource as opposed
to the recordsource.

The reason I have the combo box on a new form is that my existing form
is getting a little overcrowded with controls as it is. There simply
isn't enough space left to fit another combo box! :)


Regards
Bob


J. Goddard wrote:

Hi -

What is the recordsource for the combo/dialog box on frmSameAs? If it
refers to me!ContactID, it thinks that is a field on frmSaveAs.

You could change the combo box control source in the On Open event of
frmSaveAs:

[combobox].controlsource="Select [whatever] from [contacts] where
contactID <> '" & forms![main form]![contactID] & "'"

but that only works if you are only calling frmSameAs from the one form

Could you not just put that combo box on the main form, rather than
using a separate popup form?


Hope this helps (a bit, anyway)

John


Bob wrote:

Hi folks,

I have a command button on one of my forms which I use to open a second
form (frmSameAs) in popup mode.

frmSameAs has a combobox on it which I use to list of the contacts in
my database. I want the listing to exclude the current contact.

At the moment, the rowsource for the combo box points to a query
(qryAllOtherContacts). qryAllOtherContacts requires a value for the
current ContactID shown in my existing form (with the command button on
it).

I can open frmSameAs without a problem. But when I press the combo box
to get the drop down list it opens a dialog/parameter box asking for
Me.ContactID.

Is there a way that I can pass the ContactID in my existing form direct
to frmSameAs to provide required parameter for the query
programmatically?

I've tried setting the rowsource for frmSaveAs to "qryAllOtherContacts
WHERE ContactID<>" & Me.ContactID. But this doesn't work.



TIA
Bob
 
G

Guest

Bob:

I know you've solved this but the original problem resulted from your use of
Me.ContactID rather than a fully qualified reference to the ContactID control
on the form with the command button. If you'd made the parameter a fully
qualified reference such as Forms!frmContacts!ContactID it should have
worked.

The Me keyword is used in a class module such as a form's or report's
module, and provides a reference to the current instance of the class; think
of it as a reference to the current form or report. So your problem arose
from two things, firstly it was not in the module of the form containing the
ContactID control, and secondly it was used in the SQL of a query not in VBA.
In a query you should normally use a fully qualified reference as above.
Note that in a query you should still use the ! operator, not the . (dot)
operator which is these days generally favoured in VBA.

BTW if you are interested in how the OpenArgs property can be more flexibly
employed to pas multiple and/or named arguments rather than merely to pass a
single value take a look at my demo at:


http://community.netscape.com/n/pfx...yMessages&tsn=1&tid=24091&webtag=ws-msdevapps


Ken Sheridan
Stafford, England

Bob said:
Hi John,

I prefer to have everything visible at once rather than have the user
tab to different pages. Its just a preference thing.

By the way, I managed to resolve my problem by passing the ContactID as
an OpenArg and then simply changing my query to point to the form's
OpenArgs rather than to Me.ContactID itself. I almost had it in the
first place - at one stage I had my query pointing to Me.OpenArgs
(instead of just OpenArgs).

Hopefully this post helps someone else out there.


Regards
Bob


J. Goddard said:
An overcrowded form - have you checked out the Tab control? This *very*
useful control allows you to a) put a lot more controls on to a single
form, and b) group related controls together so users see only a few at
a time. Items common to the whole form can be outside the tab control.

John

Thanks for the response John.

The combo box is currently unbound. For this reason, I've tried
fiddling with the Open event to try and change the rowsource as opposed
to the recordsource.

The reason I have the combo box on a new form is that my existing form
is getting a little overcrowded with controls as it is. There simply
isn't enough space left to fit another combo box! :)


Regards
Bob


J. Goddard wrote:


Hi -

What is the recordsource for the combo/dialog box on frmSameAs? If it
refers to me!ContactID, it thinks that is a field on frmSaveAs.

You could change the combo box control source in the On Open event of
frmSaveAs:

[combobox].controlsource="Select [whatever] from [contacts] where
contactID <> '" & forms![main form]![contactID] & "'"

but that only works if you are only calling frmSameAs from the one form

Could you not just put that combo box on the main form, rather than
using a separate popup form?


Hope this helps (a bit, anyway)

John


Bob wrote:

Hi folks,

I have a command button on one of my forms which I use to open a second
form (frmSameAs) in popup mode.

frmSameAs has a combobox on it which I use to list of the contacts in
my database. I want the listing to exclude the current contact.

At the moment, the rowsource for the combo box points to a query
(qryAllOtherContacts). qryAllOtherContacts requires a value for the
current ContactID shown in my existing form (with the command button on
it).

I can open frmSameAs without a problem. But when I press the combo box
to get the drop down list it opens a dialog/parameter box asking for
Me.ContactID.

Is there a way that I can pass the ContactID in my existing form direct
to frmSameAs to provide required parameter for the query
programmatically?

I've tried setting the rowsource for frmSaveAs to "qryAllOtherContacts
WHERE ContactID<>" & Me.ContactID. But this doesn't work.



TIA
Bob
 

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