UtterAccess.com
X   Site Message
(Message will auto close in 2 seconds)

Welcome to UtterAccess! Please ( Login   or   Register )

Custom Search
 
   Reply to this topicStart new topic
> Presenting Code Snippet In Post    
 
   
richardp
post Aug 8 2017, 11:03 AM
Post#1



Posts: 14
Joined: 23-September 14



I want to ask a question about a snippet of code. I've seen previous posts where the poster was asked to use a "Code Box" (my term) when presenting code in a post.

Example:

DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel8, "qryCustomers", "C:\Main Folder\SubFolder\ExportToDBase2.xls", True

Could someone kindly tell me the official name of that "Code Box", and where to find instructions on how to use it?

Thanks in advance for your help.
Go to the top of the page
 
theDBguy
post Aug 8 2017, 11:07 AM
Post#2


Access Wiki and Forums Moderator
Posts: 70,391
Joined: 19-June 07
From: SunnySandyEggo


Hi Richard,

When you post a reply and want to enclose a code snippet in code tags, you can highlight the text and then click on the "Wrap in code tags" icon on the tool bar just above the reply entry box.

Hope it helps...

--------------------
Just my 2 cents... "And if I claim to be a wise man, it surely means that I don't know" - Kansas
Microsoft Access MVP | Access Website | Access Blog | Email
Go to the top of the page
 
GroverParkGeorge
post Aug 8 2017, 11:36 AM
Post#3


UA Admin
Posts: 30,219
Joined: 20-June 02
From: Newcastle, WA


Attached File  WrapInCode.png ( 20.06K )Number of downloads: 2

--------------------
Go to the top of the page
 
DanielPineault
post Aug 8 2017, 11:37 AM
Post#4


UtterAccess VIP
Posts: 5,077
Joined: 30-June 11



See the attached jpg. You can simply use the button in the editor (as shown) or manually enter the code tags yourself.

You can get more details about all the various tags/options..., see: http://www.UtterAccess.com/forum/index.php...amp;CODE=bbcode
Attached File(s)
Attached File  UACodeTags.jpg ( 18.96K )Number of downloads: 1
 

--------------------
Daniel Pineault (2010-2017 Microsoft MVP)
Professional Help: http://www.cardaconsultants.com
Free MS Access Code, Tips, Tricks and Samples: http://www.devhut.net

* Design should never say "Look at me". It should always say "Look at this". -- David Craib
* A user interface is like a joke, if you have to explain it, it's not that good! -- Martin LeBlanc


All code samples, demonstration databases, links,... are provided 'AS IS' and are to be used at your own risk! Take the necessary steps to check, validate ...
Go to the top of the page
 
doctor9
post Aug 8 2017, 12:12 PM
Post#5


UtterAccess Editor
Posts: 17,449
Joined: 29-March 05
From: Wisconsin


Richard,

You can click on the Help link in the upper right corner to see more detailed help about every control you see over the textbox where you type your post. Just scroll down to the "How to Post Questions and Add Replies" section.

Dennis

--------------------
(;,;) Li'l Cthulu says: Please talk about what you're trying to do, as well as how you're doing it.
Changing your real table name to "Table1" and your real form name to "Form1" in your posts makes it more difficult to understand what's going on, not easier.
Guidelines for Posting Questions
Go to the top of the page
 
richardp
post Aug 8 2017, 01:30 PM
Post#6



Posts: 14
Joined: 23-September 14



Thanks all.

I read through various helps offered on this Website, but didn't know the right words to use, so couldn't find the answer. I will experiment with the info provided here and add what works to my notes. Thanks again.

Testing the "Wrap in Quote Tags" option here:

QUOTE
1) DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel8, "qryCustomers", _
2) "C:\Main Folder\SubFolder\ExportToDBase2.xls", True

This post has been edited by richardp: Aug 8 2017, 01:40 PM
Go to the top of the page
 
richardp
post Aug 8 2017, 01:50 PM
Post#7



Posts: 14
Joined: 23-September 14



That seems to do the trick. I assume if the code is long enough, that scroll-bars will appear? I seem to remember scroll bars in other "Code Boxes" I've seen on this Website.

I want to place the path at 2) above into a TextBox - txtFileLocation - create a string to reference that Textbox, and substitute the string name for the path at 2) above (this will allow the user to save the exported file to a location of their choosing).

What would be the best Forum on this website in which to ask a question / explore the subject about strings? From what I've looked through, it seems that the "Access Forms" Forum would be suitable? Would you recommend a different one.

Thanks again for your help.
This post has been edited by richardp: Aug 8 2017, 01:52 PM
Go to the top of the page
 
theDBguy
post Aug 8 2017, 01:56 PM
Post#8


Access Wiki and Forums Moderator
Posts: 70,391
Joined: 19-June 07
From: SunnySandyEggo


Hi Richard,

I can't speak for everyone but I think most users here don't pay close attention to which forum to visit to answer questions. The home page lists all recent posts, and people like me use the "New Posts" link on the top menu to see the latest conversations.

So, my advice is to pick one forum to post your question; and if it happens to be a better fit somewhere else, we'll be happy to move it for you.

Cheers!

--------------------
Just my 2 cents... "And if I claim to be a wise man, it surely means that I don't know" - Kansas
Microsoft Access MVP | Access Website | Access Blog | Email
Go to the top of the page
 
richardp
post Aug 8 2017, 02:01 PM
Post#9



Posts: 14
Joined: 23-September 14



OK. Thanks. When I formulate my question and post it, I'll place a link here - for the sake of others searching for a similar answer who might happen by this post.
Go to the top of the page
 
doctor9
post Aug 8 2017, 02:06 PM
Post#10


UtterAccess Editor
Posts: 17,449
Joined: 29-March 05
From: Wisconsin


Richard,

The bare-bones version of your question seems to be this: "How do I allow the user to select which folder they export data to?"

To that I would suggest a slight alternative to your proposed textbox: Instead, invoke a folder browser that allows the user to select a folder for storing the file. Then, use the path they selected to export your file. The reason I suggest this is to remove the chance of the user typing in a path that doesn't exist or is invalid for some reason. You can find code for invoking a folder browser here, at The Access Web.

So, your code could be something like this, once you've added the code from that site:

CODE
Dim strPath as String
strPath = BrowseFolder("Where do you want to export data to?")
If strPath <> "" Then
    DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel8, "qryCustomers", strPath & "\ExportToDBase2.xls", True
    Msgbox "Data exported to " & strPath
Else
    Msgbox "Export cancelled!"
End If

Hope this helps,

Dennis

--------------------
(;,;) Li'l Cthulu says: Please talk about what you're trying to do, as well as how you're doing it.
Changing your real table name to "Table1" and your real form name to "Form1" in your posts makes it more difficult to understand what's going on, not easier.
Guidelines for Posting Questions
Go to the top of the page
 
richardp
post Aug 8 2017, 03:28 PM
Post#11



Posts: 14
Joined: 23-September 14



Thanks doctor9. I need a minute to explore the information you have given me and I'll come back later.

For others passing by later, I used the Quote tags upthread.
I was actually advised to use the Code tags.

doctor9's response caused me to revisit the responses to my question. Conclusion: if the advice doesn't seem to give you what you were looking for, first re-read the advice. dazed.gif
Go to the top of the page
 
richardp
post Aug 8 2017, 07:55 PM
Post#12



Posts: 14
Joined: 23-September 14



Dennis - the code did exactly what I need it to do. Thank you muchly.

My project is a dBase that imports an Excel file from the dBase of another organization into tblCustomers, rearranges the columns and does a text to columns routine in qryCustomers, and then exports qryCustomers into an Excel file that can be imported by the dBase of a different organization.

My Form only has an Import button and Export button, and works lickety-split - when I define the export path in the export code. Dennis, your solution allows the user to specify their own export path. Probably, I will create a choice box to use the default export path (quicker) or your search-box (a bit slower, but useful if the default export path is changed by the removal or renaming of a folder). This is being used in Access 2007 runtime, so the user may not be able to examine the default export path on their hard drive.

The import code is simply this: "DoCmd.RunCommand acCmdImportAttachExcel"

That opens a search-box similar to what your solution opens, where I can navigate to where the file I want to import is located. Such a shame that Access does not have a similiar simple command to open the search-box so the user can navigate to where they want to save the exported file.

Again, thanks Dennis for your solution. Richard
Go to the top of the page
 


Custom Search
RSSSearch   Top   Lo-Fi    21st August 2017 - 07:01 AM