Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Queries / April 2008

Tip: Looking for answers? Try searching our database.

Search based on checkboxes

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
AlexG - 22 Apr 2008 14:36 GMT
Hi all!
Here's my question:

I have created 1 table (Clients) with 10 fields (ClientID, Name, Adress,
Phone etc...).
Next, there is a form (Clients) that allows me to fill data into the
relevant fields of the table (ClientID, Name, Adress, Phone etc...)

Just below these 10 fields,  there are 5 check boxes. They are all
positioned under the text label "Client wished to contact via:" that allows
me to select one or more of the following check boxes "E-mail, Post, Tel,
Fax, Telex".

So far, so good..

The thing I would like to do is to create a form which will act as a search
form. Inside this new form, I want to be able to have the above mentioned 5
check boxes (Under the text label "Please click on the appropriate search
criteria") and to be able to select one, two or all 5 of them. Finally,
pressing the "Search now" button, a report should be generated with the
records-clients that have selected to be contacted via the selected
methods-check boxes.

Can anyone pls tell me which is the easier method to do this due to that I
am new using Access...

Sorry for the long description... Any guidance will be highly appreciated!

Tnx, AlexG
Evi - 26 Apr 2008 11:03 GMT
You might find that the GettingStarted newsgroup will be a good choice for
your questions.
Lets call your report "YourReport" and the unbound checkboxes in your form
Chk1, Chk2, Chk3 etc.
Click Properties, on the Data tab, choose False next to Default Value
Add  button to your Form and let the wizard choose to Preview  your report
Open the button's code page by going to Properties, Events and clicking next
to On Click.

Just under where it says 'Dim stDocName As String'
insert the following

   Dim Crit As String
   Dim MyLength As Long

If Me.chk1 = True Then
 Crit = Crit & "([E-mail]= TRUE) AND "
End If

If Me.chk2 = True Then
 Crit = Crit & "([Post]= TRUE) AND "
End If

If Me.chk3 = True Then
 Crit = Crit & "([Tel]= True) AND "
End If

If Me.chk4 = True Then
 Crit = Crit & "([Fax]= True) AND "
End If

If Me.chk5 = True Then
 Crit = Crit & "([Telex]= True) AND "
End If

 MyLength = Len(Crit) - 5

If MyLength <= 0 Then
 Crit = ""
Else

 Crit = Left(Crit, MyLength)
 End If

  DoCmd.OpenReport stDocName, acPreview, , Crit

End If

> Hi all!
> Here's my question:
[quoted text clipped - 25 lines]
>
> Tnx, AlexG
AlexG - 27 Apr 2008 00:47 GMT
Evi, tnx a lot for your assistance.
I have already posted the same question in the GettingStarted newsgroup..
Will be more careful next time and sorry for the double post...

Since you have provided me with some guidance, can you help me with the
"End If without block If" error that prompts me regarding the last End If?

   DoCmd.OpenReport stDocName, acPreview, , Crit

End If

End Sub

Also, when moving to another record (pressing the new record button that
have created), the checkboxes do not alter their state. They remain as
checked as when I clicked on them in the previous record...

Thank you very much. Pls inform me if I should post this question in the
GettingStarted newsgroup...

Ο χρήστης "Evi" έγγραψε:

> You might find that the GettingStarted newsgroup will be a good choice for
> your questions.
[quoted text clipped - 43 lines]
>
> End If
Evi - 27 Apr 2008 09:07 GMT
Sorry, my bad. Delete that last End If. It was a typo.

Evi
> Evi, tnx a lot for your assistance.
> I have already posted the same question in the GettingStarted newsgroup..
[quoted text clipped - 65 lines]
> >
> > End If
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.