Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 469909
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T23:49:54+00:00 2026-05-12T23:49:54+00:00

I have an embarrassing question regarding Access. I can build relational databases in my

  • 0

I have an embarrassing question regarding Access. I can build relational databases in my sleep but I have always used PHP, mySQL and HTML to build my applications.

I’ve hated Access with a passion for various reasons ever since I can remember but now I’m stuck using it for a particular project.

I have a number of tables, one of which is customer, which among other things has a username and password field.

When I start the database, I want a login form to appear, which I can do using the AutoExec macro, I’ve made the form with a username and password field. After that, I get stuck with the logic of querying for the username/password and then showing a new form if correct or an error if not.

Could anyone help me out with making the macro and query work together?

Clarification: I am trying to do this without coding whole Visual Basic macros, if at all possible, I want to be able to do it using the macro builder thingumy.

Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T23:49:55+00:00Added an answer on May 12, 2026 at 11:49 pm

    Malphas –

    It is actually possible to do this without using VBA, but I am wondering whether the reason why you don’t want to use VBA is because of the Trust issue. In which case, this won’t be possible, because the macro actions Close and Quit are disallowed if the database is not trusted.

    Whilst you can to run actions in the AutoExec macro beyond the point where you use the OpenForm command, I think it is neater to continue the next actions on the form itself. First because you can’t really do branching in a macro; secondly because it is more modular to keep actions to do with the form actually on the form.

    In the example below, my sample login form is called LoginForm, and the username text box is txtUserName, and the password text box is called txtPassword.

    The first thing to do is to protect the dialogue from the simple act of letting the user close the dialogue and escape into the database design screen. The best way to do this is to set a flag called ValidLogin when the form loads. You will set this flag during the login process. When the form is closed, check whether the flag is true. If ValidLogin is false, then close the database.

    On the OnLoad event of the Login form, click on the ellipsis button, and choose Macros Builder. In the Macro screen, use the following actions (note that the Condition column is hidden by default – but you’ll only need for the next two macros):

    Line Condition     Action/Arguments
    
    1                  SetTempVar, Name = ValidLogin, Expression = False
    

    On the OnUnload event of the Login form, do the same as above, and add:

    Line Condition     Action/Arguments
    
    1  Not [TempVars]![ValidLogin]
                       Quit, Options = Exit.
    

    If you run this now, as soon as you close the form, the database will close. To be useful, you need to add the following macro actions to the OnClick event of your Login button:

    Line Condition     Action/Arguments
    
    1                  SetTempVar, Name = Valid Login, Expression = DCount("*","Customer","[Username]=[Forms]![LoginForm]![txtUserName] And [Password]=[Forms]![LoginForm]![txtPassword]")>0
    
    2 Not [TempVars]![ValidLogin]
                       MsgBox, Message = Invalid Login
    3 ...              StopMacro
    
    4                  OpenForm, Form Name = MainForm
    
    5                  Close, Object Type = Form, Object Name = LoginForm, Save = No
    

    Note that in all these examples, I have used embedded macros, not named macros, so you can keep them together with the form. Also note the ellipsis (…) in the last macro, which represents the value of the last condition.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This question is almost embarrassing to ask, but I can't find the answer in
So this is a pretty embarrassing question, but i have a text file and
This is a very basic question...quite embarassing, but here goes: I have a Stopwatch
Embarrassing question really -- I have Subsonic collection, then I filter out some data
This probably is a very very basic question but i can't seem to find
This question is so basic, it's kind of embarrassing, but here goes... This is
I'm revealing my embarrassing ignorance of REGEX-fu here, but: I currently have a website
Quick embrassing question. I have been looking for a PHP function that would calculate
Ok this is embarrassingly simple of a question, but I just can't get this
Ok this is kind of embarassing but I just have a rather noob question.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.