View Full Version : how to separate reports/tables?


AndreasWN
09-25-2007, 06:41 AM
Hi
I'm new with Access and I have this problem that I really hope someone can help me with:
I have some customers in an Access DB and they are separated into the different towns where they live. I want to make a button where I can export the names and adresses of my customers to a comma delimited txt-file, but ONLY the ones who live in the town I decide to view/work with in Access.
I have made a button that exports all customers but as mentioned I only want to export some. The button looks like this:
__________________________________________________ _________________
Private Sub send_rapport_til_fil_Click()
On Error GoTo Err_send_rapport_til_fil_Click

Dim stDocName As String
stDocName = "Klienter Query"

DoCmd.TransferText acExportDelim, , "Klienter Query", "report.txt", False
Exit_send_rapport_til_fil_Click:
Exit Sub

Err_send_rapport_til_fil_Click:
MsgBox Err.Description
Resume Exit_send_rapport_til_fil_Click

End Sub
__________________________________________________ ___________
I also have another button that prints out labels with names of the people in the DB. That button works, so only the names of the selected town will be printed. Maybe I can use something from that string? Anyway it looks like this:
__________________________________________________ ___________
Private Sub Command16_Click()
Dim stDocName As String
Dim stLinkCriteria As String

Me.Refresh
stDocName = "Kuverter"
If param = 1 Then
stLinkCriteria = "[BibliotekID]=" & Me![BibliotekID]
Else
stLinkCriteria = "[BibliotekID]=" & Forms![Klienter Query]![BibliotekID]
End If

DoCmd.OpenReport stDocName, acNormal, , stLinkCriteria
'printes kun 1 gang

End Sub
__________________________________________________ ___________
I really hope someone can help me, I'm in trouble getting this to work.
Thanks in advance.
-Andreas

KenHigg
09-25-2007, 06:51 AM
For the first part - I usually create a small popup form that has a combo box on it where the user selects an option then use this as a filter (criteria) for the report recordsource.

:)
ken

AndreasWN
09-25-2007, 07:03 AM
Ah, Ok. That's a good idea. Do you make this popup in the button-wizard, or can you apply it later on in visualbasic? Thanks a lot for your reply!
-Andreas

KenHigg
09-25-2007, 07:05 AM
I'm not aware of a wizard to do this - You'll have to bite the bullet and do a little vba :)

:)
ken

AndreasWN
09-25-2007, 07:08 AM
You wouldn't happen to have the arguments/visualbasic commands for making such a filter lying around?
:) Thanks

KenHigg
09-25-2007, 07:16 AM
Look at this simple example...

AndreasWN
09-25-2007, 07:20 AM
Thank you !
It couldn't be better. I will try to integrate this in my DB!
I have really appreciated your help
-Andreas

KenHigg
09-25-2007, 07:23 AM
Glad to help - :)

ken