472,126 Members | 1,523 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,126 software developers and data experts.

Open Another Database from a Form

1 Bit
I have great difficulty getting to grips with Access VBA. I have copied the example given on this subject into a standard module (I assume it is a Function) and have tried several others. The code will not run, I get an 'Expected: end of Statement' error. It seems I have left out something basic and would be grateful for any advice. Regards
Nov 30 '21 #1
2 17394
32,497 Expert Mod 16PB
Hi James.

Welcome to Bytes.com.

I suspect you were so confused by the problem in front of you that you let it take your concentration away from your question. When you post a question you will always have to consider it from the perspective of someone who doesn't already know what you're struggling with. They (We) will have to rely on two things :
  1. Their own experience & expertise.
  2. Whatever you include in your question about your problem or issue.
In this case we all have the first, but there is next to nothing of the second to work from (or on). The error message is great. More than we often find ourselves with. The code you have in your Standard Module is fundamental to the context though. Without that we are very much limited (In this case limited to almost nothing at all.) in what we can do to help.

I would guess, if your intention is to open another database from a Form, that you would want the code to be in the module associated with that Form, but with so little info available at this time I can't be sure. We can probably cover that later on when we know more.

I suspect your next reply should include :
  1. The code that you have in your module. At least all that's relevant to this task.)
  2. An explanation of what you're trying to do. Opening a database can be the description of three different things :
    1. Opening a database in the current session as the main database (CurrentDatabase in Access terms). This would necessarily close the current CurrentDatabase (which of course means the one the code is running from).
    2. Opening a new copy of Access and specifying a database it should open as it does so. This is a completely different Access session and doesn't otherwise affect the existing CurrentDatabase or running code.
    3. Opening another database within the same session as a simple database (as opposed to the CurrentDatabase). Access can handle multiple databases in a session but only ever one CurrentDatabase at a time.
Once we know what you are actually looking for I'm sure there will be many here willing to help. As I write this I see that 37 have already viewed it. Most of those will have been with a view to help if they can but were put off by the lack of sense in the question itself. Once you rectify that I would expect many to help.
Nov 30 '21 #2
32,497 Expert Mod 16PB
Hi again James.

As you're clearly new I thought Before Posting (VBA or SQL) Code would help you avoid many of the early pitfalls new users stumble across.

In this case I would recommend going through an attempted compile first and either fixing any obvious errors or sharing them here so we can help with that.

This is the base level - to get your code syntax so that at least it's valid VBA code. If there are logic errors too then clearing away the syntax errors first will generally simplify the work to find and fix those.

Remember always, however eager we are to help (and that's generally pretty eager TBF), we can only do so when we understand what your problem is. Easy? Complicated? Generally unimportant. If you need help then the chances are that others may need the same type of help so many will be helped off the back of helping you.
Nov 30 '21 #3

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

1 post views Thread by kevcar40 | last post: by
5 posts views Thread by BD | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.