+ Reply to Thread
Results 1 to 23 of 23

Not a valid file name

  1. #1
    Registered User
    Join Date
    01-09-2016
    Location
    england
    MS-Off Ver
    2016
    Posts
    50

    Unhappy Not a valid file name

    Hi there,

    I am trying to write a code to connect my excel userforms to my access database to launch queries from excel.
    However, I get an error saying that "cntStudConnection.Open ConnectionString:=cnctSource" is not a valid file name and microsoft has no help solutions.

    Here is my code:
    Please Login or Register  to view this content.
    I am quite new to this so any help is welcomed !

    Thank you

  2. #2
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,721

    Re: Not a valid file name

    The character ":" is not a valid character for a Windows filename. The following characters are illegal:

    \ / : * ? " < > |
    Jeff
    | | |會 |會 |會 |會 | |:| | |會 |會
    Read the rules
    Use code tags to [code]enclose your code![/code]

  3. #3
    Registered User
    Join Date
    01-09-2016
    Location
    england
    MS-Off Ver
    2016
    Posts
    50

    Re: Not a valid file name

    I've removed the ":", and now get "data source name not found and no default driver specified"
    But i've checked the location several times and do no see any issues

    thank you for your help !

  4. #4
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,721

    Re: Not a valid file name

    That sounds like a different problem related to your Access connection. Unfortunately I have no experience integrating Excel and Access.

  5. #5
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,566

    Re: Not a valid file name

    Is this correct?
    Please Login or Register  to view this content.

  6. #6
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,721

    Re: Not a valid file name

    Quote Originally Posted by jindon View Post
    Is this correct?
    Please Login or Register  to view this content.
    Good catch! That can't possibly be correct. That will result in a string like this, which is nonsense.

    C:\Users\Hala\Documents\My SpreadsheetsC:\Users\Hala\Documents\BBB\Dummydata1.accdb

    Where is your Access file, and does it depend on the location of your Excel file?

  7. #7
    Registered User
    Join Date
    01-09-2016
    Location
    england
    MS-Off Ver
    2016
    Posts
    50

    Re: Not a valid file name

    My access database is in "C:\Users\Hala\Documents\BBB\Dummydata1.acdb"

    I've tried removing "Thisworkbook.path" and now get "Data source name not found and no default driver specified".
    Please Login or Register  to view this content.
    is still highlighted

  8. #8
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,566

    Re: Not a valid file name

    My access database is in "C:\Users\Hala\Documents\BBB\Dummydata1.acdb"
    Isn't it accdb?
    Last edited by jindon; 01-10-2016 at 03:27 AM.

  9. #9
    Registered User
    Join Date
    01-09-2016
    Location
    england
    MS-Off Ver
    2016
    Posts
    50

    Re: Not a valid file name

    Yes sorry ! Made a typo error but its correctly written in my code

  10. #10
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,566

    Re: Not a valid file name

    How about
    Please Login or Register  to view this content.

  11. #11
    Registered User
    Join Date
    01-09-2016
    Location
    england
    MS-Off Ver
    2016
    Posts
    50

    Re: Not a valid file name

    Yes it worked thank you !!

    I am calling this connection with a command button with code
    Please Login or Register  to view this content.
    Could I set a message box as the range instead of the sheet ? I do not want the data to appear on the sheet.

  12. #12
    Registered User
    Join Date
    01-09-2016
    Location
    england
    MS-Off Ver
    2016
    Posts
    50

    Re: Not a valid file name

    Yes it worked thank you !!

    I am calling this connection with a command button with code
    Please Login or Register  to view this content.
    Could I set a message box as the range instead of the sheet ? I do not want the data to appear on the sheet.

  13. #13
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,566

    Re: Not a valid file name

    Not really sure though...
    Please Login or Register  to view this content.

  14. #14
    Registered User
    Join Date
    01-09-2016
    Location
    england
    MS-Off Ver
    2016
    Posts
    50

    Re: Not a valid file name

    Yes that works !

    I've set the range as msg in my command button code and get this
    AufL3BNrJqZs54HJqIHRIhIfI2bXHvWUDKC4ynEnMANF.jpg

    But i remember being told that a msgbox has a character limit which might be why it does not display all the values that it should.

    Would calling a userform that displayed the table be possible ?

  15. #15
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,566

    Re: Not a valid file name

    Possible, something like
    Please Login or Register  to view this content.
    Instead of msgbox...

  16. #16
    Registered User
    Join Date
    01-09-2016
    Location
    england
    MS-Off Ver
    2016
    Posts
    50

    Re: Not a valid file name

    Yes, i've created the new userform with the text box as big as the form and edited the module function to set msg as the textbox in the new userform

    I just have to now find a way to insert the data into a table. I get everything in one line

    Aq8bJ9p42304Zc6D_jzmo4M5CwDHmNBbs9iClGMZsQjR.jpg

    Unfortunately i cannot find anything online that indicated that i could display that so not sure if it is even possible ?

  17. #17
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,566

    Re: Not a valid file name

    Try replace vbLf with vbCrLf in msg.

  18. #18
    Forum Expert JapanDave's Avatar
    Join Date
    06-10-2008
    Location
    The grid, I got in!
    MS-Off Ver
    Excel 2010/13
    Posts
    1,696

    Re: Not a valid file name

    I would use this,
    Please Login or Register  to view this content.
    Please Login or Register  to view this content.
    Pretty much does the same thing. I try to avoid them if I can.
    Be fore warned, I regularly post drunk. So don't take offence (too much) to what I say.
    I am the real 'Napster'
    The Grid. A digital frontier. I tried to picture clusters of information as they moved through the computer. What did they look like? Ships? motorcycles? Were the circuits like freeways? I kept dreaming of a world I thought I'd never see. And then, one day...

    If you receive help please give thanks. Click the * in the bottom left hand corner.

    snb's VBA Help Files

  19. #19
    Registered User
    Join Date
    01-09-2016
    Location
    england
    MS-Off Ver
    2016
    Posts
    50

    Re: Not a valid file name

    I've tried vbNewline, vbCrLf, vbCr, vbLf but still get a line result

  20. #20
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,566

    Re: Not a valid file name

    Have you set the MultiLine property for TextBox to True?

  21. #21
    Registered User
    Join Date
    01-09-2016
    Location
    england
    MS-Off Ver
    2016
    Posts
    50

    Re: Not a valid file name

    Sorry i did not know about that property !
    It works now thank you !

    I just have two last questions if you do not mind,
    1. I have 1000 values in my access database and the textbox only displays the information that fits into the frame. Is there any other tool that would solve this ? (Like a scroll bar maybe ?)
    2. Also, since i apparently cannot create a table with this data should i assume that i cannot create a graph either ?

  22. #22
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,566

    Re: Not a valid file name

    You can also set AutoSize property to True and see how it goes.
    Also you can select ScrollBars property to show.

  23. #23
    Registered User
    Join Date
    01-09-2016
    Location
    england
    MS-Off Ver
    2016
    Posts
    50

    Re: Not a valid file name

    All done thank you !

    Marking this thread as solved

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. File format or file extension is not valid
    By maytps in forum Excel General
    Replies: 9
    Last Post: 08-09-2015, 11:14 PM
  2. Excel file format or file extension is not valid
    By Ivangashkin in forum Excel General
    Replies: 3
    Last Post: 12-28-2014, 02:31 PM
  3. Replies: 1
    Last Post: 05-08-2014, 12:36 PM
  4. File format is not valid - opening word file by vba
    By matsuchika in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 02-13-2013, 01:36 PM
  5. [SOLVED] Frequently used file suddenly becomes 'not a valid file name'
    By Dirk Bordet in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-05-2005, 11:05 PM
  6. Frequently used file suddenly becomes 'not a valid file name'
    By Dirk Bordet in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-05-2005, 10:05 PM
  7. [SOLVED] Frequently used file suddenly becomes 'not a valid file name'
    By Dirk Bordet in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 06-06-2005, 01:05 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1