Value of an Query PARAM in VBA

  • Thread starter Thread starter Fred
  • Start date Start date
F

Fred

Hi,
In my report form I have a parameter [mois] that is setted when loading the
report by the user.. (its in my "local" query and also show in the form like
:
CDate("1/" & [mois] & "/" & Année(Date()))
that is the value of a text field.
What I'd like to, is to
access thisvalue through VBA...
how do I access this param ?
Because instead of having it set when loading the report, I ve done a form
where the use just select the value, click ok and then the report should
read this value when loading and use it asthe parameter...

Private Sub Report_Open(Cancel As Integer)
mois = Forms![Accueil]![val_mois]
End Sub

Thank you
 
If you have this form field bound to the database field you don't need to access it in code, when the user selects it from a listbox or combo box the value will be stored in the field then you can use code lik

Set dbDatabase = DBEngine.Workspaces(0).Databases(0
Set rsDatabase = dbDatabase.OpenRecordset(strDate, DB_OPEN_DYNASET
moise = rsDatabase![moise

Once you have this field value in VB with this method you can use it for anything, to populate reports or as selection criteria

If you aren't storing it to a database but just passing it around you can just assign the report fields content to a global variable in code to use again like you were doing in your message. If you do it this way your going to have to set the contents of your text box CDate("1/" & [mois] & "/" & Année(Date())) in code like your doing, not in the box on the form so it can access the variable
 
Back
Top