Ok, I feel pretty stupid asking a question that has been asked so many times, but I've been searching on and reading this board all afternoon and something just isn't clicking for me.
I started with This Thread to learn how to do an awesome calendar and link it to my query to run a report. That worked great and I achieved some basic understanding of what I am doing.
Next I tried to copy this form and add another field to run a different type of report. I want Form2 to run the same query, but of course the variables for the dates didn't work because they call to the original form. I started searching here and tried a couple different things that were suggested, but I think I'm just missing something...
First I thought I needed to set the startdate and enddate as variables in a module, so I did this in Module1:
Then, within the form I tried to work in these variables (without really understanding what I was doing, mind you!)
Then I tried to work this into the criteria a couple different ways, again not knowing exactly how. This didn't work.
Then I read some stuff that lead me to think I could just set the form as the public variable and keep the txtclick1 and txtclick2 variables in the form. So I added this to my module1:
And this into my form:
I really thought this might have worked, but I couldn't get the syntax in the criteria field of the query to work at all.
I realize, through reading through all the great help on this forum that I'm missing something which is probably pretty fundamental, most likely in how to change the criteria expression to what I need. If anyone could help me out I'd sure appreciate it.
Thanks,
Kyle
I started with This Thread to learn how to do an awesome calendar and link it to my query to run a report. That worked great and I achieved some basic understanding of what I am doing.
Next I tried to copy this form and add another field to run a different type of report. I want Form2 to run the same query, but of course the variables for the dates didn't work because they call to the original form. I started searching here and tried a couple different things that were suggested, but I think I'm just missing something...
First I thought I needed to set the startdate and enddate as variables in a module, so I did this in Module1:
Code:
Option Compare Database
Option Explicit
Public startdate As Date, enddate As Date
Then, within the form I tried to work in these variables (without really understanding what I was doing, mind you!)
Code:
Private Sub atxCalControl1_Click()
Me.txtClick1.Value = Me.atxCalControl1.Value
startdate = Me.atxCalControl1.Value 'added by me
Me.Refresh
End Sub
Private Sub atxCalControl2_Click()
Me.txtClick2.Value = Me.atxCalControl2.Value + 0.99999 '
enddate = Me.atxCalControl2.Value + 0.99999 ' added by me
Me.Refresh
End Sub
Then I tried to work this into the criteria a couple different ways, again not knowing exactly how. This didn't work.
Then I read some stuff that lead me to think I could just set the form as the public variable and keep the txtclick1 and txtclick2 variables in the form. So I added this to my module1:
Code:
Public Function GetFormName() As String
If ((IsNull(strMyForm)) Or (strMyForm = vbNullString)) Then Exit Function
GetFormName = strMyForm
End Function
And this into my form:
Code:
Public Function GetFormName() As String
Private Sub Form_Load()
Me.atxCalControl1.Value = Now()
Me.atxCalControl2.Value = Now()
strMyForm = Me.Name ' added by me
End Sub
I really thought this might have worked, but I couldn't get the syntax in the criteria field of the query to work at all.
I realize, through reading through all the great help on this forum that I'm missing something which is probably pretty fundamental, most likely in how to change the criteria expression to what I need. If anyone could help me out I'd sure appreciate it.
Thanks,
Kyle