A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

More Q: on combo boxes



 
 
Thread Tools Display Modes
  #1  
Old September 12th, 2007, 01:13 PM posted to microsoft.public.access.forms
Ana[_3_]
external usenet poster
 
Posts: 12
Default More Q: on combo boxes

Hi,

In a form, I had a combo box which selecting CLIENT_ID would trigger a
report with said client info base on the following expression:



DoCmd.OpenReport stDocName, acViewPreview, , " [CLIENT_ID] = " &
Me!Combo25.Column(0)

Me!Combo25 = ""



I now need the combo to look at two parameters: CLIENT_ID and STATUS_ID
before passing the info to the report.

I added STATUS_ID in the combo query and a second column so that CLIENT_ID
and STATUS_NAME can be displayed. (Select CLIENT_ID, STATUS_NAME,
STATUS_ID..)



I'd imagine I need to do the following?:



DoCmd.OpenReport stDocName, acViewPreview, , " [SOLICITUD_ID] AND
[dbo.TIPO_SOLICITUD.TIPO_SOLICITUD_ID] = " & Me!Combo25.Column(0) and &
Me!Combo25.Column(2)

Me!Combo25 = ""



Any help is appreciated.

TIA

Ana

  #2  
Old September 12th, 2007, 01:24 PM posted to microsoft.public.access.forms
Ana[_3_]
external usenet poster
 
Posts: 12
Default More Q: on combo boxes

I ment:

DoCmd.OpenReport stDocName, acViewPreview, , " [CLIENT_ID] AND
[STATUS_ID] = " & Me!Combo25.Column(0) and &
Me!Combo25.Column(2)
Me!Combo25 = ""

  #3  
Old September 12th, 2007, 01:45 PM posted to microsoft.public.access.forms
Douglas J. Steele
external usenet poster
 
Posts: 9,313
Default More Q: on combo boxes

DoCmd.OpenReport stDocName, acViewPreview, , _
"[CLIENT_ID] = " & Me!Combo25.Column(0) & _
" AND [STATUS_ID] = " Me!Combo25.Column(2)

This assumes that both CLIENT_ID and STATUS_ID are numeric fields. If, for
example,STATUS_ID was a text field, you'd need to include quotes:

DoCmd.OpenReport stDocName, acViewPreview, , _
"[CLIENT_ID] = " & Me!Combo25.Column(0) & _
" AND [STATUS_ID] = '" Me!Combo25.Column(2) & "'"

Exagerated for clarity, that last line is


" AND [STATUS_ID] = ' " Me!Combo25.Column(2) & " ' "

Incidentally, if you're trying to unselect what ever was selected in the
combo box after you open the report, you might be better using

Me!Combo25 = Null

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)


"Ana" wrote in message
...
I ment:

DoCmd.OpenReport stDocName, acViewPreview, , " [CLIENT_ID] AND [STATUS_ID]
= " & Me!Combo25.Column(0) and & Me!Combo25.Column(2)
Me!Combo25 = ""



  #4  
Old September 12th, 2007, 03:51 PM posted to microsoft.public.access.forms
Ana[_3_]
external usenet poster
 
Posts: 12
Default More Q: on combo boxes

Hi Douglas,
I made the changes you suggested but the report still isn't using status_id
as reference, it only looks at client_id (both client_ and status_id are
int). I need to force the report (or query) to use both ids as reference.
Any ideas?
Thanks much.
Ana

"Douglas J. Steele" escribió en el
mensaje de noticias ...
DoCmd.OpenReport stDocName, acViewPreview, , _
"[CLIENT_ID] = " & Me!Combo25.Column(0) & _
" AND [STATUS_ID] = " Me!Combo25.Column(2)

This assumes that both CLIENT_ID and STATUS_ID are numeric fields. If, for
example,STATUS_ID was a text field, you'd need to include quotes:

DoCmd.OpenReport stDocName, acViewPreview, , _
"[CLIENT_ID] = " & Me!Combo25.Column(0) & _
" AND [STATUS_ID] = '" Me!Combo25.Column(2) & "'"

Exagerated for clarity, that last line is


" AND [STATUS_ID] = ' " Me!Combo25.Column(2) & " ' "

Incidentally, if you're trying to unselect what ever was selected in the
combo box after you open the report, you might be better using

Me!Combo25 = Null

--


  #5  
Old September 12th, 2007, 04:30 PM posted to microsoft.public.access.forms
Douglas J. Steele
external usenet poster
 
Posts: 9,313
Default More Q: on combo boxes

It should work.

What does your code look like now? What happens when the code runs? Do you
get an error? If so, what's the error? If you don't get an error, does the
report show all status ids, or a subset (the wrong subset) for each client?

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)


"Ana" wrote in message
...
Hi Douglas,
I made the changes you suggested but the report still isn't using
status_id
as reference, it only looks at client_id (both client_ and status_id are
int). I need to force the report (or query) to use both ids as reference.
Any ideas?
Thanks much.
Ana

"Douglas J. Steele" escribió en el
mensaje de noticias ...
DoCmd.OpenReport stDocName, acViewPreview, , _
"[CLIENT_ID] = " & Me!Combo25.Column(0) & _
" AND [STATUS_ID] = " Me!Combo25.Column(2)

This assumes that both CLIENT_ID and STATUS_ID are numeric fields. If,
for
example,STATUS_ID was a text field, you'd need to include quotes:

DoCmd.OpenReport stDocName, acViewPreview, , _
"[CLIENT_ID] = " & Me!Combo25.Column(0) & _
" AND [STATUS_ID] = '" Me!Combo25.Column(2) & "'"

Exagerated for clarity, that last line is


" AND [STATUS_ID] = ' " Me!Combo25.Column(2) & " ' "

Incidentally, if you're trying to unselect what ever was selected in the
combo box after you open the report, you might be better using

Me!Combo25 = Null

--




  #6  
Old September 12th, 2007, 04:42 PM posted to microsoft.public.access.forms
Ana[_3_]
external usenet poster
 
Posts: 12
Default More Q: on combo boxes

The form works so I don't get any errors.
However, the report still bases on client_id. In my case, I have 2 client_id
with the same number. To differenciate them, status_id is used. That's why
it's important that both ids are trasfered to the report.
The report is linked to a query which has both ids selected.
I think the problem is that on the form I have to select the main column as
reference so by default, column(1) is selected (client_id). If I can select
2 columns may solve my problem but it appears that Access doesn't allow it.
Rgs,
Ana

"Douglas J. Steele" escribió en el
mensaje de noticias ...
It should work.

What does your code look like now? What happens when the code runs? Do you
get an error? If so, what's the error? If you don't get an error, does the
report show all status ids, or a subset (the wrong subset) for each
client?

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)


"Ana" wrote in message
...
Hi Douglas,
I made the changes you suggested but the report still isn't using
status_id
as reference, it only looks at client_id (both client_ and status_id are
int). I need to force the report (or query) to use both ids as reference.
Any ideas?
Thanks much.
Ana

"Douglas J. Steele" escribió en el
mensaje de noticias ...
DoCmd.OpenReport stDocName, acViewPreview, , _
"[CLIENT_ID] = " & Me!Combo25.Column(0) & _
" AND [STATUS_ID] = " Me!Combo25.Column(2)

This assumes that both CLIENT_ID and STATUS_ID are numeric fields. If,
for
example,STATUS_ID was a text field, you'd need to include quotes:

DoCmd.OpenReport stDocName, acViewPreview, , _
"[CLIENT_ID] = " & Me!Combo25.Column(0) & _
" AND [STATUS_ID] = '" Me!Combo25.Column(2) & "'"

Exagerated for clarity, that last line is


" AND [STATUS_ID] = ' " Me!Combo25.Column(2) & " ' "

Incidentally, if you're trying to unselect what ever was selected in the
combo box after you open the report, you might be better using

Me!Combo25 = Null

--





  #7  
Old September 12th, 2007, 05:45 PM posted to microsoft.public.access.forms
Douglas J. Steele
external usenet poster
 
Posts: 9,313
Default More Q: on combo boxes

Is the Status_ID in the 3rd column of the combo box? That's what your code
assumes.

DoCmd.OpenReport stDocName, acViewPreview, , _
"[CLIENT_ID] = " & Me!Combo25.Column(0) & _
" AND [STATUS_ID] = " Me!Combo25.Column(2)

Try this.

Dim strCriteria As String

strCriteria = "[CLIENT_ID] = " & Me!Combo25.Column(0) & _
" AND [STATUS_ID] = " Me!Combo25.Column(2)
MsgBox strCriteria
DoCmd.OpenReport stDocName, acViewPreview, , strCriteria

Does the message box contain what you expect?

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)


"Ana" wrote in message
news
The form works so I don't get any errors.
However, the report still bases on client_id. In my case, I have 2
client_id with the same number. To differenciate them, status_id is used.
That's why it's important that both ids are trasfered to the report.
The report is linked to a query which has both ids selected.
I think the problem is that on the form I have to select the main column
as reference so by default, column(1) is selected (client_id). If I can
select 2 columns may solve my problem but it appears that Access doesn't
allow it.
Rgs,
Ana

"Douglas J. Steele" escribió en el
mensaje de noticias ...
It should work.

What does your code look like now? What happens when the code runs? Do
you get an error? If so, what's the error? If you don't get an error,
does the report show all status ids, or a subset (the wrong subset) for
each client?

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)


"Ana" wrote in message
...
Hi Douglas,
I made the changes you suggested but the report still isn't using
status_id
as reference, it only looks at client_id (both client_ and status_id are
int). I need to force the report (or query) to use both ids as
reference.
Any ideas?
Thanks much.
Ana

"Douglas J. Steele" escribió en el
mensaje de noticias ...
DoCmd.OpenReport stDocName, acViewPreview, , _
"[CLIENT_ID] = " & Me!Combo25.Column(0) & _
" AND [STATUS_ID] = " Me!Combo25.Column(2)

This assumes that both CLIENT_ID and STATUS_ID are numeric fields. If,
for
example,STATUS_ID was a text field, you'd need to include quotes:

DoCmd.OpenReport stDocName, acViewPreview, , _
"[CLIENT_ID] = " & Me!Combo25.Column(0) & _
" AND [STATUS_ID] = '" Me!Combo25.Column(2) & "'"

Exagerated for clarity, that last line is


" AND [STATUS_ID] = ' " Me!Combo25.Column(2) & " ' "

Incidentally, if you're trying to unselect what ever was selected in
the
combo box after you open the report, you might be better using

Me!Combo25 = Null

--






  #8  
Old September 12th, 2007, 06:21 PM posted to microsoft.public.access.forms
Ana[_3_]
external usenet poster
 
Posts: 12
Default More Q: on combo boxes

Is the Status_ID in the 3rd column of the combo box? That's what your code
assumes.

Yes. I've Status_Name as a second column (1)


Dim strCriteria As String

strCriteria = "[CLIENT_ID] = " & Me!Combo25.Column(0) & _
" AND [STATUS_ID] = " Me!Combo25.Column(2)
MsgBox strCriteria
DoCmd.OpenReport stDocName, acViewPreview, , strCriteria

Does the message box contain what you expect?


Yes. It displays: [CLIENT_ID] = AND [STATUS_ID] =
However, if I change ...Column(2) to ....Column(1), the box displays the
same msg as above.
In few words, the combo box doesn't see (or pass) anything but column(0).

  #9  
Old September 12th, 2007, 06:32 PM posted to microsoft.public.access.forms
Douglas J. Steele
external usenet poster
 
Posts: 9,313
Default More Q: on combo boxes

I'm guessing that the ColumnCount property of the combo box doesn't reflect
the true count.

The Column collection only goes as high as the ColumnCount property says to.

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)


"Ana" wrote in message
...
Is the Status_ID in the 3rd column of the combo box? That's what your code
assumes.

Yes. I've Status_Name as a second column (1)


Dim strCriteria As String

strCriteria = "[CLIENT_ID] = " & Me!Combo25.Column(0) & _
" AND [STATUS_ID] = " Me!Combo25.Column(2)
MsgBox strCriteria
DoCmd.OpenReport stDocName, acViewPreview, , strCriteria

Does the message box contain what you expect?


Yes. It displays: [CLIENT_ID] = AND [STATUS_ID] =
However, if I change ...Column(2) to ....Column(1), the box displays the
same msg as above.
In few words, the combo box doesn't see (or pass) anything but column(0).



  #10  
Old September 12th, 2007, 07:30 PM posted to microsoft.public.access.forms
Ana[_3_]
external usenet poster
 
Posts: 12
Default More Q: on combo boxes

Douglas,
Is there a way around?
TIA
Ana

"Douglas J. Steele" escribió en el
mensaje de noticias ...
I'm guessing that the ColumnCount property of the combo box doesn't
reflect the true count.

The Column collection only goes as high as the ColumnCount property says
to.

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)


"Ana" wrote in message
...
Is the Status_ID in the 3rd column of the combo box? That's what your
code
assumes.

Yes. I've Status_Name as a second column (1)


Dim strCriteria As String

strCriteria = "[CLIENT_ID] = " & Me!Combo25.Column(0) & _
" AND [STATUS_ID] = " Me!Combo25.Column(2)
MsgBox strCriteria
DoCmd.OpenReport stDocName, acViewPreview, , strCriteria

Does the message box contain what you expect?


Yes. It displays: [CLIENT_ID] = AND [STATUS_ID] =
However, if I change ...Column(2) to ....Column(1), the box displays the
same msg as above.
In few words, the combo box doesn't see (or pass) anything but column(0).




 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 03:37 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.