DaveEntact
New member
- Local time
- Today, 07:31
- Joined
- Oct 7, 2021
- Messages
- 6
Trying to add a button to my form that will export ONLY one field on the form to rtf. I'm new to this so don't know the code.
guy,Hi. Welcome to AWF!
Probably the easiest route is to create a query to return the single field you want to export and then use a macro to export it (the query).
Hi. You are correct. The exported file will contain the pipes. Are you looking for a way to not have the pipes? Since the OP is exporting it to RTF, it would have a normal table borders instead.guy,
will that create designing pipes with the single field values as well? I know if tables get exported and they are opened up in notepad, the vals are surrounded by pipes. will this happen here too?
no i'm not looking for anything. i was just asking a question. thanks!Hi. You are correct. The exported file will contain the pipes. Are you looking for a way to not have the pipes? Since the OP is exporting it to RTF, it would have a normal table borders instead.
I'm new to this so not sure how to do this. Would I select Export_Word in Property Sheet then add [Event Procedure] then add the code there? And where would I add the qryFieldname?create a Query outputting the single field:
(qryFieldname)
select Fieldname1 from yourTable;
you can use Macro to export the query (ExportWithFormatting).
just complete the required textbox on the macro design.
use DoCmd.OutputTo, in VBA.
DoCmd.OutputTo objecttype:=acOutputQuery, objectname:="yourQueryName", outputformat:=acFormatRTF, outputfile:="d:\output.rtf"
Make the query return only one field and only one record.Ok it works with the code
DoCmd.OutputTo objecttype:=acOutputQuery, objectname:="yourQueryName", outputformat:=acFormatRTF, outputfile:="d:\output.rtf"
but that exports all the records. I want the button to export just one field from one record.
not sure how to do thatMake the query return only one field and only one record.
Show us your query and tell us which field and which record you want.not sure how to do that
This is the codeShow us your query and tell us which field and which record you want.
Hmm, I asked you to show us your query, but you decide to show us your code instead. Unfortunately, we won't be able to answer your question from that piece of information. The code is correct, and it works. The only problem is it will export the entire content of "ResumeExport Query." So, the approach we need to take is make sure "ResumeExport Query" only contains the selected record by the user. And to do that, we'll need to see that query (ResumeExport Query). And by that, I mean, can you please post the SQL statement for that query? Thank you.This is the code
DoCmd.OutputTo objecttype:=acOutputQuery, objectname:="ResumeExport Query", outputformat:=acFormatRTF, outputfile:="output.rtf"
The Query just has one field listed. I want the user to be able to open the form then select a random record and click an Export to RTF button that exports a particular field on that record.
Sorry. Very new to this. Is this what you are talking about:Hmm, I asked you to show us your query, but you decide to show us your code instead. Unfortunately, we won't be able to answer your question from that piece of information. The code is correct, and it works. The only problem is it will export the entire content of "ResumeExport Query." So, the approach we need to take is make sure "ResumeExport Query" only contains the selected record by the user. And to do that, we'll need to see that query (ResumeExport Query). And by that, I mean, can you please post the SQL statement for that query? Thank you.
Yes, that's a good start. Okay, the query is pulling all [Resume] from the Contacts table. If there are more than one contacts, then the query will return all of them - not just one. Now, you said you wanted the user to select a contact from a form - the one they want to export. In that case, you'll have to add a WHERE clause to that query to only return the Resume for the selected Contact. Here's an example.Sorry. Very new to this. Is this what you are talking about:
SELECT Contacts.[Resume]
FROM Contacts;
SELECT [Resume] FROM Contacts WHERE ContactID=Forms!FormName.ContactID
You can use Button with embedded Macro to Export your whatever you like to RTFTrying to add a button to my form that will export ONLY one field on the form to rtf. I'm new to this so don't know the code.