Query problems

Albilly

Registered User.
Local time
Yesterday, 22:16
Joined
Nov 25, 2015
Messages
31
Hi, I have the following Q:
SELECT LISTE_CONFORMITE_HISTO_DETAIL.*, LISTE_CONFORMITE_HISTO_DETAIL.AUTRES_MOIS
FROM LISTE_CONFORMITE_HISTO_DETAIL
WHERE (((LISTE_CONFORMITE_HISTO_DETAIL_MOIS.AUTRES_MOIS)=[Forms]![CONFORMITE_HISTO_LISTE].[cboFiltreMois]![Value]));

When thew query is being execute it is always asking for a value, the value is coming from a control in the form. Since I have been away from MSAccess for too long I am not sure about the proper syntax
What shouls it be
forms!FormName.ControlName! and then what ? I have tried the cbo.value and the field name of the rowsource of the control but no success

Any solution is much appreciated
 
remove ![Value] from your sql.
 
tried it and I still get the pop up asking to enter a parameter this is the new syntax I am using :
SELECT LISTE_CONFORMITE_HISTO_DETAIL.*, LISTE_CONFORMITE_HISTO_DETAIL.AUTRES_MOIS
FROM LISTE_CONFORMITE_HISTO_DETAIL
WHERE (((LISTE_CONFORMITE_HISTO_DETAIL_MOIS.AUTRES_MOIS)=[Forms]![CONFORMITE_HISTO_LISTE]![cboFiltreMois]));
 
you need to untick 'show' in the query grid for AUTRES_MOIS

you say
asking to enter a parameter
what is the parameter it is asking for?
 
please see the worddoc attached for a printscreen
 

Attachments

so that answers your question

your table is called

LISTE_CONFORMITE_HISTO_DETAIL

but your criteria is using

LISTE_CONFORMITE_HISTO_DETAIL_MOIS

A recommendation to make your code more readable

don't use all capitals for table and field names, use what is called camel case. And ideally don't use underscores since as in this case it can be difficult to see where names begin and end


Code:
 SELECT ListeConformiteHistoDetail.*
 FROM ListeConformiteHistoDetail
 WHERE ListeConformiteHistoDetail.AutresMois=[Forms]![ConformiteHistoListe]![cboFiltreMois]
 
THis is somelse db I just pickup and trust me on this one, I was completly stunt with what I saw in it, var not declare at all, function not been called properly and most of all, all tables, forms, reports, queries are all caps with no prefix to ID them properly, really sad
 
Hi,
I just tried some variable of your code and when I run it I stil lget the enter parameter value box with the name of the cbo selection, am I missing something here ?
THis is the real code line:
Me.Form.RecordSource = "SELECT LISTE_CONFORMITE_HISTO_DETAIL.* From LISTE_CONFORMITE_HISTO_DETAIL WHERE LISTE_CONFORMITE_HISTO_DETAIL.Autres_Mois = " & strVal
 
I stil lget the enter parameter value box with the name of the cbo selection
I don't see the name of your cbo, I see strVal. Please provide the rest of your code.
 
Private Sub cboFiltreMois_Change()
'filter data based on MOIS only, to disregard all other options
Dim strVal As String
strVal = "SELECT LISTE_CONFORMITE_HISTO_DETAIL.* From LISTE_CONFORMITE_HISTO_DETAIL WHERE LISTE_CONFORMITE_HISTO_DETAIL.Autres_Mois = " & Me.cboFiltreMois
'Debug.Print strVal

Me.Form.RecordSource = strVal
Me.Form.Requery
End Sub
 
if Autres_Mois is a string then it should be

....WHERE LISTE_CONFORMITE_HISTO_DETAIL.Autres_Mois = '" & Me.cboFiltreMois & "'"

- use of single quotes

note the change event is probably not the right one to use, suggest afterupdate. Reason is that if the user types rather than selecting from a dropdown, the code will be triggered after each character is entered or deleted
 
Many Thanks,
should have tought about it, the after_update is not an option since this cbo is used only as a way to filter information only not updating any value at all, so everytime the use select a month, the list is to be refreshed based on the new selection only.

I wil ltest it up tomorrow morning, the code I have to go thru just to make sure I do not damage anything else is just mind bottleling, would you like to take a peak at it just to see by yourself ( for fun of course)

Again Thanks alot
 
would you like to take a peak at it just to see by yourself ( for fun of course)
no thanks! I have enough nightmares of my own....

everytime the use select a month, the list is to be refreshed based on the new selection only.
So long as uthe user doesn't type 'J..a...n' you'll be OK

The afterupdate event for the cbo refers to the control, not the entire form
 
the control is set to select from the list only, no modif or typing of any kind, I am safe on that

Regards
 
try it - OK they can only select from the list, but they can still type 'J'
 

Users who are viewing this thread

Back
Top Bottom