combo box + help

T

tomato

Hi.

I have a combo box that has no relationship with the form
recordsource query. This combo box record source is a
query that select 2 fields from one table, which again has
nothing to do with the form recordsource.
This combo box displays 2 fields(IssueNumber, IssueDate).
Bound Column is IssueNumber. Since it seems like there is
no way to bind more than one field as bound column, I
cannot hold IssueDate anywhere on the form. So, I am
trying to create a hidden text field that holds IssueDate
after the combo box is selected.
I have same kind of combo boxes on the same form, which
work fine because they relate to the form recordsource
query. But, for this combo box, I tried to write a code
to run query again to retrieve IssueDate, but don't know
how to return the value to the hidden text box on the same
form.
Please help me if you know a way to make this thing work.
 
A

Allen Browne

You could use the AfterUpdate event procedure of the combo to write the date
to your hidden text box:
Me.MyHiddenTextbox = Me.MyCombo.Column(1)
 
T

tomato

Thanks, Allen.
I tried what you advised me. But getting error.
I add [event procedure]in After_update on the combo box.
the code is the following.

Private Sub StartingIssue_AfterUpdate()
Me.StartingIssueDate = Me.StartingIssue.Column(2)
End Sub

"StartingIssueDate" is the name of the hidden text box.
I am trying to insert the second column of the combo box,
which holds date. I believe I should be putting some
thing in the control source, but not sure what.
What am I supposed to enter in the control source for
the hidden text box?

Hope you can help me.
 
A

Allen Browne

I should have explained that Column is a zero-based property, i.e. the first
column is zero, so the 2nd one is called Column(1).

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

tomato said:
Thanks, Allen.
I tried what you advised me. But getting error.
I add [event procedure]in After_update on the combo box.
the code is the following.

Private Sub StartingIssue_AfterUpdate()
Me.StartingIssueDate = Me.StartingIssue.Column(2)
End Sub

"StartingIssueDate" is the name of the hidden text box.
I am trying to insert the second column of the combo box,
which holds date. I believe I should be putting some
thing in the control source, but not sure what.
What am I supposed to enter in the control source for
the hidden text box?

Hope you can help me.
-----Original Message-----
You could use the AfterUpdate event procedure of the combo to write the date
to your hidden text box:
Me.MyHiddenTextbox = Me.MyCombo.Column(1)
work.
 
T

tomato

I realized that column number should be 1 right after I
posted my response. So, I did.
But I get an error "Cannot insert this value to this text
box"(This is not an exact words, but something like
this).So I debug the code, stop debugging and go back to
access. Then the value is already in the hidden text box
as it supposed to be. But cannot get rid of this error
message and stop the program. What do you think is the
problem?
-----Original Message-----
I should have explained that Column is a zero-based property, i.e. the first
column is zero, so the 2nd one is called Column(1).

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

Thanks, Allen.
I tried what you advised me. But getting error.
I add [event procedure]in After_update on the combo box.
the code is the following.

Private Sub StartingIssue_AfterUpdate()
Me.StartingIssueDate = Me.StartingIssue.Column(2)
End Sub

"StartingIssueDate" is the name of the hidden text box.
I am trying to insert the second column of the combo box,
which holds date. I believe I should be putting some
thing in the control source, but not sure what.
What am I supposed to enter in the control source for
the hidden text box?

Hope you can help me.
-----Original Message-----
You could use the AfterUpdate event procedure of the combo to write the date
to your hidden text box:
Me.MyHiddenTextbox = Me.MyCombo.Column(1)


Hi.

I have a combo box that has no relationship with the form
recordsource query. This combo box record source is a
query that select 2 fields from one table, which
again
has
nothing to do with the form recordsource.
This combo box displays 2 fields(IssueNumber, IssueDate).
Bound Column is IssueNumber. Since it seems like
there
is
no way to bind more than one field as bound column, I
cannot hold IssueDate anywhere on the form. So, I am
trying to create a hidden text field that holds IssueDate
after the combo box is selected.
I have same kind of combo boxes on the same form, which
work fine because they relate to the form recordsource
query. But, for this combo box, I tried to write a code
to run query again to retrieve IssueDate, but don't know
how to return the value to the hidden text box on the same
form.
Please help me if you know a way to make this thing
work.


.
 
A

Allen Browne

There are 2 ways to do this:
1. Leave the text box unbound (nothing in its control source), and use the
AfterUpdate event procedure of the combo to assign a value,

or

2. Set the controlSource of the text box to:
=Me.StartingIssue.Column(1)
and don't use the event procedure.

Don't try to do both.

Given the way you explained the issue, I suspect that #1 is likely to give
better results (since the bound column of the combo does not have unique
values).

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

tomato said:
I realized that column number should be 1 right after I
posted my response. So, I did.
But I get an error "Cannot insert this value to this text
box"(This is not an exact words, but something like
this).So I debug the code, stop debugging and go back to
access. Then the value is already in the hidden text box
as it supposed to be. But cannot get rid of this error
message and stop the program. What do you think is the
problem?
-----Original Message-----
I should have explained that Column is a zero-based property, i.e. the first
column is zero, so the 2nd one is called Column(1).

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

Thanks, Allen.
I tried what you advised me. But getting error.
I add [event procedure]in After_update on the combo box.
the code is the following.

Private Sub StartingIssue_AfterUpdate()
Me.StartingIssueDate = Me.StartingIssue.Column(2)
End Sub

"StartingIssueDate" is the name of the hidden text box.
I am trying to insert the second column of the combo box,
which holds date. I believe I should be putting some
thing in the control source, but not sure what.
What am I supposed to enter in the control source for
the hidden text box?

Hope you can help me.

-----Original Message-----
You could use the AfterUpdate event procedure of the
combo to write the date
to your hidden text box:
Me.MyHiddenTextbox = Me.MyCombo.Column(1)


message
Hi.

I have a combo box that has no relationship with the
form
recordsource query. This combo box record source is a
query that select 2 fields from one table, which again
has
nothing to do with the form recordsource.
This combo box displays 2 fields(IssueNumber,
IssueDate).
Bound Column is IssueNumber. Since it seems like there
is
no way to bind more than one field as bound column, I
cannot hold IssueDate anywhere on the form. So, I am
trying to create a hidden text field that holds
IssueDate
after the combo box is selected.
I have same kind of combo boxes on the same form, which
work fine because they relate to the form recordsource
query. But, for this combo box, I tried to write a code
to run query again to retrieve IssueDate, but don't know
how to return the value to the hidden text box on the
same
form.
Please help me if you know a way to make this thing
work.
 
T

tomato

Thank you so much, Allen.
I tried the first way and it worked!!!
-----Original Message-----
There are 2 ways to do this:
1. Leave the text box unbound (nothing in its control source), and use the
AfterUpdate event procedure of the combo to assign a value,

or

2. Set the controlSource of the text box to:
=Me.StartingIssue.Column(1)
and don't use the event procedure.

Don't try to do both.

Given the way you explained the issue, I suspect that #1 is likely to give
better results (since the bound column of the combo does not have unique
values).

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

I realized that column number should be 1 right after I
posted my response. So, I did.
But I get an error "Cannot insert this value to this text
box"(This is not an exact words, but something like
this).So I debug the code, stop debugging and go back to
access. Then the value is already in the hidden text box
as it supposed to be. But cannot get rid of this error
message and stop the program. What do you think is the
problem?
-----Original Message-----
I should have explained that Column is a zero-based property, i.e. the first
column is zero, so the 2nd one is called Column(1).

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

Thanks, Allen.
I tried what you advised me. But getting error.
I add [event procedure]in After_update on the combo box.
the code is the following.

Private Sub StartingIssue_AfterUpdate()
Me.StartingIssueDate = Me.StartingIssue.Column(2)
End Sub

"StartingIssueDate" is the name of the hidden text box.
I am trying to insert the second column of the combo box,
which holds date. I believe I should be putting some
thing in the control source, but not sure what.
What am I supposed to enter in the control source for
the hidden text box?

Hope you can help me.

-----Original Message-----
You could use the AfterUpdate event procedure of the
combo to write the date
to your hidden text box:
Me.MyHiddenTextbox = Me.MyCombo.Column(1)


message
Hi.

I have a combo box that has no relationship with the
form
recordsource query. This combo box record source is a
query that select 2 fields from one table, which again
has
nothing to do with the form recordsource.
This combo box displays 2 fields(IssueNumber,
IssueDate).
Bound Column is IssueNumber. Since it seems like there
is
no way to bind more than one field as bound column, I
cannot hold IssueDate anywhere on the form. So, I am
trying to create a hidden text field that holds
IssueDate
after the combo box is selected.
I have same kind of combo boxes on the same form, which
work fine because they relate to the form recordsource
query. But, for this combo box, I tried to write a code
to run query again to retrieve IssueDate, but don't know
how to return the value to the hidden text box on the
same
form.
Please help me if you know a way to make this thing
work.


.
 

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