CuppyCakes
Technical User
Hi
So I have never coded a day in my life up until about last week when deciding that there was no way to get around it to make the data base I am working on to function the way I want it to, so please bare with me. I'm Uber Noob.
Pretty much what I have so far is my form with all of my unbound text boxes where I want to input the data that I want to filter my results by. And originally just had a couple like functions and a query that a ran and produced the data on the sub-form below the unbound text boxes. But you have to have each of the different criteria (unbound txt boxes) filled out for that to work and I don't want the user to have to enter in all of them if they don't want to. So, trying to make a long story short, I attempted to write a code that would filter my data for me and still produce said data on the sub-form. But not only does my code not do anything (I'm a lame code writer) but I don't know where to begin to make my data appear on my sub-form.
I am officially lost and have found these forums amazingly helpful and thought maybe someone might know how to help :/
Here is my code (thought this might be useful lol)( yes, that is actually what I named my btn)
Private Sub btnVBAttempt_Click()
Public Function getWhere() As String
Dim strProject As String
Dim strAssignment As String
Dim strWorkWeek As String
Dim frm As Access.Form
Set frm = Forms("frmSearch")
'get Project
If Not Trim(frm.txtProject & " ") = "" Then
strProject = "([Project] = '" & frm.txtProject & "') OR "
End If
'get Assignment
If Not Trim(frm.txtAssignment & " ") = "" Then
strAssignment = "([Assignment] = '" & frm.txtAssignment & "') OR "
End If
'getWorkWeek
If IsWorkWeek(frm.txtMinWorkWeek) And IsWorkWeek(frm.txtMaxWorkWeek) Then
strWorkWeek = "([WorkWeek] Between #" & frm.txtMinWorkWeek & "# AND #" & frm.txtMaxWorkWeek & "#) OR "
End If
'Add together
getWhere = strProject & strAssignment & strCompleted & strWorkWeek
'Remove the hanging OR
getWhere = Left(getWhere, Len(getWhere) - 4)
End Function
End Sub
pretty much any advice at this point would be useful.
Thanks!
CuppyCakes
So I have never coded a day in my life up until about last week when deciding that there was no way to get around it to make the data base I am working on to function the way I want it to, so please bare with me. I'm Uber Noob.
Pretty much what I have so far is my form with all of my unbound text boxes where I want to input the data that I want to filter my results by. And originally just had a couple like functions and a query that a ran and produced the data on the sub-form below the unbound text boxes. But you have to have each of the different criteria (unbound txt boxes) filled out for that to work and I don't want the user to have to enter in all of them if they don't want to. So, trying to make a long story short, I attempted to write a code that would filter my data for me and still produce said data on the sub-form. But not only does my code not do anything (I'm a lame code writer) but I don't know where to begin to make my data appear on my sub-form.
I am officially lost and have found these forums amazingly helpful and thought maybe someone might know how to help :/
Here is my code (thought this might be useful lol)( yes, that is actually what I named my btn)
Private Sub btnVBAttempt_Click()
Public Function getWhere() As String
Dim strProject As String
Dim strAssignment As String
Dim strWorkWeek As String
Dim frm As Access.Form
Set frm = Forms("frmSearch")
'get Project
If Not Trim(frm.txtProject & " ") = "" Then
strProject = "([Project] = '" & frm.txtProject & "') OR "
End If
'get Assignment
If Not Trim(frm.txtAssignment & " ") = "" Then
strAssignment = "([Assignment] = '" & frm.txtAssignment & "') OR "
End If
'getWorkWeek
If IsWorkWeek(frm.txtMinWorkWeek) And IsWorkWeek(frm.txtMaxWorkWeek) Then
strWorkWeek = "([WorkWeek] Between #" & frm.txtMinWorkWeek & "# AND #" & frm.txtMaxWorkWeek & "#) OR "
End If
'Add together
getWhere = strProject & strAssignment & strCompleted & strWorkWeek
'Remove the hanging OR
getWhere = Left(getWhere, Len(getWhere) - 4)
End Function
End Sub
pretty much any advice at this point would be useful.
Thanks!
CuppyCakes