Revisit Need to remove "/" from date?

W

Weeble

I said your sugestion worked, but I hadn't tried them. I can't get them to
work. I tried applying them to the form control as well as the sub. I get
some unusual dates and the "/" are still there.

Perhaps you could tell me where to use the Format() function to make this
work.

Again, Thanks.
 
C

Chegu Tom

Show us the code where you take the initials and add the date (as you now do
it that has the / characters)

Then we can tell you where to apply the format function
 
W

Weeble

strDate = Me.DateControl.Value
strDate = Format(strDate,"mmddyy")

strPath1 = "C:\Documents and Settings\mjonkman\My Documents\Daily Logs"
strPath1 = strPath1 & "\" & strYear & "\" & strMonth
strPath1 = strPath1 & "\DZ" & strDate & ".xls"

Note that strYear and strMonth are not dates but refer to sub directories in
the Daily Logs directory.
 
C

Chegu Tom

It should work as you show it here. I suspect that you strDate doesn't
contain what you think it does

Go to VB screen and immediate mode and try a couple of dates to see how the
format works

try
print format(date(),"yyyymmdd")
print format ("12/29/09,"yyyymmdd")
etc to see what results the formater gives you

or you can add lines to your code

debug.print strDate
debug.print format(strdate,"yyyymmdd")

Run your code and then look in the immedate area of the vba window to see
what was printed
 
K

KARL DEWEY

I tried applying them to the form control as well as the sub.
What do you mean by 'sub.'
Your orignal says you were exporting report to Excel. Did you try using the
Format function in the query that feeds the report?
 
W

Weeble

Karl,

Actually I misspoke myself. I am exporting the Query to Excell. Sorry for
the confusion.

I will try working with the code in my sub. If you see anything that I am
doing wrong, please advise.

Thanks,
 
W

Weeble

Thanks for the direction. I will try working with this and see where it takes
me. The Immediate mode is new to me so that will take a little research. I'll
post back if I just can't figure it out.

I did create a work around that is more labor intensive for the operator,
but this kind of defeats the point of automating processes.

Again, Thanks.
 
W

Weeble

I found my problem. The date control I was referencing was in a page header
on the form. I had intended to create a form header but created the former in
my hurry. Why my sub wouldn't read the date properly from the page header is
a mystery to me, but once I put the date control in a form header it reads
fine and formats perfectly.

Thanks to everyone.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top