Display problem on the SubForm

J

Jeff

Hi,

I have two bounded ComboBoxes, cbxDrName & cbxDrComment, on a SubForm
(MySubForm). What I want to do is when people select a name from cbxDrName,
the cbxDrComment will display a certain doctor's comments for selection. It
works well with the following codes if I open the SubForm by itself.

Private Sub cbxDrName_AfterUpdate()
Me![cbxDrComment].Requery
Me![ cbxDrComment] = ""
End Sub

RowSource in my cbxDrComment is SELECT tbComment.DrComment FROM tbComment
WHERE (((tbComment.DrName)=[Forms]![MySubForm].[cbxDrName]));

If I place MySubForm on a MainForm (MyMainForm), Access will pop up a
windows to let me input cbxDrName when I open MyMainForm with MySubForm on it.

Your help will be appreciated.
 
M

Maurice

place the name of your main form also in the rowsource... like:

RowSource in my cbxDrComment is SELECT tbComment.DrComment FROM tbComment
WHERE (((tbComment.DrName)=[Forms]![Mainform]![MySubForm].[cbxDrName]));

replace the [Mainform] with the name of the mainform name and give it a go..
 
J

Jeff

Hi Maurice,
Thank you very much for your quick response. It still pops up a windows to
let me input cbxDrName. It's very curious, I use this method on a single form
several times and it works well. I also try that clause with .......WHERE
(((tbComment.DrName)='John')) and it works. There must be something wrong
with this clause. Is there any difference if cbxDrComment is bounded or
unbounded?
Jeff


"Maurice" 來函:
place the name of your main form also in the rowsource... like:

RowSource in my cbxDrComment is SELECT tbComment.DrComment FROM tbComment
WHERE (((tbComment.DrName)=[Forms]![Mainform]![MySubForm].[cbxDrName]));

replace the [Mainform] with the name of the mainform name and give it a go..
--
Maurice Ausum


Jeff said:
Hi,

I have two bounded ComboBoxes, cbxDrName & cbxDrComment, on a SubForm
(MySubForm). What I want to do is when people select a name from cbxDrName,
the cbxDrComment will display a certain doctor's comments for selection. It
works well with the following codes if I open the SubForm by itself.

Private Sub cbxDrName_AfterUpdate()
Me![cbxDrComment].Requery
Me![ cbxDrComment] = ""
End Sub

RowSource in my cbxDrComment is SELECT tbComment.DrComment FROM tbComment
WHERE (((tbComment.DrName)=[Forms]![MySubForm].[cbxDrName]));

If I place MySubForm on a MainForm (MyMainForm), Access will pop up a
windows to let me input cbxDrName when I open MyMainForm with MySubForm on it.

Your help will be appreciated.
 
M

Maurice

Ok it's a string value you are returning, try this:

SELECT tbComment.DrComment FROM tbComment WHERE tbComment.DrName ='" &
[Forms]![Mainform]![MySubForm].[cbxDrName] & "'"

That's a double, single and a double quote again after the & -sign
and a single and a double quote after the = -sign
--
Maurice Ausum


Jeff said:
Hi Maurice,
Thank you very much for your quick response. It still pops up a windows to
let me input cbxDrName. It's very curious, I use this method on a single form
several times and it works well. I also try that clause with .......WHERE
(((tbComment.DrName)='John')) and it works. There must be something wrong
with this clause. Is there any difference if cbxDrComment is bounded or
unbounded?
Jeff


"Maurice" 來函:
place the name of your main form also in the rowsource... like:

RowSource in my cbxDrComment is SELECT tbComment.DrComment FROM tbComment
WHERE (((tbComment.DrName)=[Forms]![Mainform]![MySubForm].[cbxDrName]));

replace the [Mainform] with the name of the mainform name and give it a go..
--
Maurice Ausum


Jeff said:
Hi,

I have two bounded ComboBoxes, cbxDrName & cbxDrComment, on a SubForm
(MySubForm). What I want to do is when people select a name from cbxDrName,
the cbxDrComment will display a certain doctor's comments for selection. It
works well with the following codes if I open the SubForm by itself.

Private Sub cbxDrName_AfterUpdate()
Me![cbxDrComment].Requery
Me![ cbxDrComment] = ""
End Sub

RowSource in my cbxDrComment is SELECT tbComment.DrComment FROM tbComment
WHERE (((tbComment.DrName)=[Forms]![MySubForm].[cbxDrName]));

If I place MySubForm on a MainForm (MyMainForm), Access will pop up a
windows to let me input cbxDrName when I open MyMainForm with MySubForm on it.

Your help will be appreciated.
 
J

Jeff

Hi Maurice,

Thank you. Access returns a syntax error. I even build a Query and place the
Query in cbxComment's RowSource, but it still doesn't work.
--
Jeff


"Maurice" 來函:
Ok it's a string value you are returning, try this:

SELECT tbComment.DrComment FROM tbComment WHERE tbComment.DrName ='" &
[Forms]![Mainform]![MySubForm].[cbxDrName] & "'"

That's a double, single and a double quote again after the & -sign
and a single and a double quote after the = -sign
--
Maurice Ausum


Jeff said:
Hi Maurice,
Thank you very much for your quick response. It still pops up a windows to
let me input cbxDrName. It's very curious, I use this method on a single form
several times and it works well. I also try that clause with .......WHERE
(((tbComment.DrName)='John')) and it works. There must be something wrong
with this clause. Is there any difference if cbxDrComment is bounded or
unbounded?
Jeff


"Maurice" 來函:
place the name of your main form also in the rowsource... like:

RowSource in my cbxDrComment is SELECT tbComment.DrComment FROM tbComment
WHERE (((tbComment.DrName)=[Forms]![Mainform]![MySubForm].[cbxDrName]));

replace the [Mainform] with the name of the mainform name and give it a go..
--
Maurice Ausum


:

Hi,

I have two bounded ComboBoxes, cbxDrName & cbxDrComment, on a SubForm
(MySubForm). What I want to do is when people select a name from cbxDrName,
the cbxDrComment will display a certain doctor's comments for selection. It
works well with the following codes if I open the SubForm by itself.

Private Sub cbxDrName_AfterUpdate()
Me![cbxDrComment].Requery
Me![ cbxDrComment] = ""
End Sub

RowSource in my cbxDrComment is SELECT tbComment.DrComment FROM tbComment
WHERE (((tbComment.DrName)=[Forms]![MySubForm].[cbxDrName]));

If I place MySubForm on a MainForm (MyMainForm), Access will pop up a
windows to let me input cbxDrName when I open MyMainForm with MySubForm on it.

Your help will be appreciated.
 
M

Maurice

Hi Jeff,

Sorry for the delay...

Did you replace the [Mainform] bit for [MyMainform]?

it should look like this at the end:

SELECT tbComment.DrComment FROM tbComment WHERE tbComment.DrName ='" &
[Forms]![MyMainform]![MySubForm].[cbxDrName] & "'"

because in the initial post you state that the name of your mainform is
MyMainform. In the previous samples we are referring to [Mainform].


hth
--
Maurice Ausum


Jeff said:
Hi Maurice,

Thank you. Access returns a syntax error. I even build a Query and place the
Query in cbxComment's RowSource, but it still doesn't work.
--
Jeff


"Maurice" 來函:
Ok it's a string value you are returning, try this:

SELECT tbComment.DrComment FROM tbComment WHERE tbComment.DrName ='" &
[Forms]![Mainform]![MySubForm].[cbxDrName] & "'"

That's a double, single and a double quote again after the & -sign
and a single and a double quote after the = -sign
--
Maurice Ausum


Jeff said:
Hi Maurice,
Thank you very much for your quick response. It still pops up a windows to
let me input cbxDrName. It's very curious, I use this method on a single form
several times and it works well. I also try that clause with .......WHERE
(((tbComment.DrName)='John')) and it works. There must be something wrong
with this clause. Is there any difference if cbxDrComment is bounded or
unbounded?
Jeff


"Maurice" 來函:

place the name of your main form also in the rowsource... like:

RowSource in my cbxDrComment is SELECT tbComment.DrComment FROM tbComment
WHERE (((tbComment.DrName)=[Forms]![Mainform]![MySubForm].[cbxDrName]));

replace the [Mainform] with the name of the mainform name and give it a go..
--
Maurice Ausum


:

Hi,

I have two bounded ComboBoxes, cbxDrName & cbxDrComment, on a SubForm
(MySubForm). What I want to do is when people select a name from cbxDrName,
the cbxDrComment will display a certain doctor's comments for selection. It
works well with the following codes if I open the SubForm by itself.

Private Sub cbxDrName_AfterUpdate()
Me![cbxDrComment].Requery
Me![ cbxDrComment] = ""
End Sub

RowSource in my cbxDrComment is SELECT tbComment.DrComment FROM tbComment
WHERE (((tbComment.DrName)=[Forms]![MySubForm].[cbxDrName]));

If I place MySubForm on a MainForm (MyMainForm), Access will pop up a
windows to let me input cbxDrName when I open MyMainForm with MySubForm on it.

Your help will be appreciated.
 
J

Jeff

Hi Maurice,

I am sorry I forgot to mention that I place that clause in the control's
RowSource, not in VBA codes. I finally get it work by changing the name of
the SubForm control to make it different from the name of the SubForm, and
refer to the SubForm control in stead of referring to the SubForm. It works
as follow:

Forms!MyMainForm!SubformControl.Form!cbxDrName

I found this in other posts in this forum. Anyway, thank you very much.

--
Jeff


Maurice said:
Hi Jeff,

Sorry for the delay...

Did you replace the [Mainform] bit for [MyMainform]?

it should look like this at the end:

SELECT tbComment.DrComment FROM tbComment WHERE tbComment.DrName ='" &
[Forms]![MyMainform]![MySubForm].[cbxDrName] & "'"

because in the initial post you state that the name of your mainform is
MyMainform. In the previous samples we are referring to [Mainform].


hth
--
Maurice Ausum


Jeff said:
Hi Maurice,

Thank you. Access returns a syntax error. I even build a Query and place the
Query in cbxComment's RowSource, but it still doesn't work.
--
Jeff


"Maurice" 來函:
Ok it's a string value you are returning, try this:

SELECT tbComment.DrComment FROM tbComment WHERE tbComment.DrName ='" &
[Forms]![Mainform]![MySubForm].[cbxDrName] & "'"

That's a double, single and a double quote again after the & -sign
and a single and a double quote after the = -sign
--
Maurice Ausum


:

Hi Maurice,
Thank you very much for your quick response. It still pops up a windows to
let me input cbxDrName. It's very curious, I use this method on a single form
several times and it works well. I also try that clause with .......WHERE
(((tbComment.DrName)='John')) and it works. There must be something wrong
with this clause. Is there any difference if cbxDrComment is bounded or
unbounded?
Jeff


"Maurice" 來函:

place the name of your main form also in the rowsource... like:

RowSource in my cbxDrComment is SELECT tbComment.DrComment FROM tbComment
WHERE (((tbComment.DrName)=[Forms]![Mainform]![MySubForm].[cbxDrName]));

replace the [Mainform] with the name of the mainform name and give it a go..
--
Maurice Ausum


:

Hi,

I have two bounded ComboBoxes, cbxDrName & cbxDrComment, on a SubForm
(MySubForm). What I want to do is when people select a name from cbxDrName,
the cbxDrComment will display a certain doctor's comments for selection. It
works well with the following codes if I open the SubForm by itself.

Private Sub cbxDrName_AfterUpdate()
Me![cbxDrComment].Requery
Me![ cbxDrComment] = ""
End Sub

RowSource in my cbxDrComment is SELECT tbComment.DrComment FROM tbComment
WHERE (((tbComment.DrName)=[Forms]![MySubForm].[cbxDrName]));

If I place MySubForm on a MainForm (MyMainForm), Access will pop up a
windows to let me input cbxDrName when I open MyMainForm with MySubForm on it.

Your help will be appreciated.
 
M

Maurice

No problem glad you got it working :)

Tip: Forms!MyMainForm!SubformControl.Form!cbxDrName

memorize this line your going to need it a lot!

cheers.
--
Maurice Ausum


Jeff said:
Hi Maurice,

I am sorry I forgot to mention that I place that clause in the control's
RowSource, not in VBA codes. I finally get it work by changing the name of
the SubForm control to make it different from the name of the SubForm, and
refer to the SubForm control in stead of referring to the SubForm. It works
as follow:

Forms!MyMainForm!SubformControl.Form!cbxDrName

I found this in other posts in this forum. Anyway, thank you very much.

--
Jeff


Maurice said:
Hi Jeff,

Sorry for the delay...

Did you replace the [Mainform] bit for [MyMainform]?

it should look like this at the end:

SELECT tbComment.DrComment FROM tbComment WHERE tbComment.DrName ='" &
[Forms]![MyMainform]![MySubForm].[cbxDrName] & "'"

because in the initial post you state that the name of your mainform is
MyMainform. In the previous samples we are referring to [Mainform].


hth
--
Maurice Ausum


Jeff said:
Hi Maurice,

Thank you. Access returns a syntax error. I even build a Query and place the
Query in cbxComment's RowSource, but it still doesn't work.
--
Jeff


"Maurice" 來函:

Ok it's a string value you are returning, try this:

SELECT tbComment.DrComment FROM tbComment WHERE tbComment.DrName ='" &
[Forms]![Mainform]![MySubForm].[cbxDrName] & "'"

That's a double, single and a double quote again after the & -sign
and a single and a double quote after the = -sign
--
Maurice Ausum


:

Hi Maurice,
Thank you very much for your quick response. It still pops up a windows to
let me input cbxDrName. It's very curious, I use this method on a single form
several times and it works well. I also try that clause with .......WHERE
(((tbComment.DrName)='John')) and it works. There must be something wrong
with this clause. Is there any difference if cbxDrComment is bounded or
unbounded?
Jeff


"Maurice" 來函:

place the name of your main form also in the rowsource... like:

RowSource in my cbxDrComment is SELECT tbComment.DrComment FROM tbComment
WHERE (((tbComment.DrName)=[Forms]![Mainform]![MySubForm].[cbxDrName]));

replace the [Mainform] with the name of the mainform name and give it a go..
--
Maurice Ausum


:

Hi,

I have two bounded ComboBoxes, cbxDrName & cbxDrComment, on a SubForm
(MySubForm). What I want to do is when people select a name from cbxDrName,
the cbxDrComment will display a certain doctor's comments for selection. It
works well with the following codes if I open the SubForm by itself.

Private Sub cbxDrName_AfterUpdate()
Me![cbxDrComment].Requery
Me![ cbxDrComment] = ""
End Sub

RowSource in my cbxDrComment is SELECT tbComment.DrComment FROM tbComment
WHERE (((tbComment.DrName)=[Forms]![MySubForm].[cbxDrName]));

If I place MySubForm on a MainForm (MyMainForm), Access will pop up a
windows to let me input cbxDrName when I open MyMainForm with MySubForm on it.

Your help will be appreciated.
 

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