VBA code

jrsarrat

New Member
Joined
Jul 8, 2018
Messages
47
Hi there!

I have created a login screen for users, and installed a VBA code to notify them of a successful or unsuccessful login (with the click of a button). From a successful login, I would like Access to default to a specified form to add new records. What code would I use? Do I enter the command in the same VBA box I stored the other command?
 

Excel Facts

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.
You should be able to use the "DoCmd.OpenForm..." command to open the Form.
Just place that right in your current VBA code in the appropriate place.
https://msdn.microsoft.com/en-us/vba/access-vba/articles/docmd-openform-method-access

Fixed! Thank you!

I'm also trying to restrict access to all tables/forms but 1 for most of my users. I have already created an EmployeeAccess table to specify privileges; I just need to create the codes for restricting the access. How do I start from the beginning?
 
Upvote 0
Fixed! Thank you!
You are welcome.

I'm also trying to restrict access to all tables/forms but 1 for most of my users. I have already created an EmployeeAccess table to specify privileges; I just need to create the codes for restricting the access. How do I start from the beginning?
Since that is a new question, it is best to post it in a new thread.

The general rule of thumb is if the question is a directly-related follow-up that only makes sense if the reader sees the previous question, then post it in the same thread.
If it is a new question not dependent upon the previous answer (even if it is the same "project"), it is best to post it in a new thread. That way others will see it as a new question without any answers (especially since this is a topic I really cannot provide much help with).

That being said, note that Access Security has limitations and vulnerabilities.
See: https://www.devhut.net/2016/08/19/why-ms-access-isnt-a-secure-database/
and item 11 here: https://www.techrepublic.com/blog/1...os-hate-microsoft-access-but-really-shouldnt/
 
Upvote 0
Surely a successful login message is not needed?. if it is successful, you show them the form else they get an unsuccessful message.?
 
Upvote 0
Yes, you're right. That's what I changed it to. Thank you.
Another issue - I want to add a command that will open a new record, instead of the opening the form on the last entry. Please help me?
 
Upvote 0
Take a look at the DataMode argument of OpenForm. There is an option to open the Form in "Add" mode (which would be used to add new records).
 
Upvote 0
Take a look at the DataMode argument of OpenForm. There is an option to open the Form in "Add" mode (which would be used to add new records).

Hi Joe4!

Thank you for your reply.
I attempted to update the command but I did not see an option resembling "Add" in the DataMode argument...
I see acDesign, etc.
 
Upvote 0
This is what it looks like in VBA:
Code:
DoCmd.OpenForm "FormName", acNormal, "", "", [COLOR=#ff0000]acAdd[/COLOR], acNormal
 
Upvote 0
This is what it looks like in VBA:
Code:
DoCmd.OpenForm "FormName", acNormal, "", "", [COLOR=#ff0000]acAdd[/COLOR], acNormal

Awesome! Thank you!
My new conundrum is this - My "Find Record" button on the form is not available now -- "The command or action 'Find' isn't available now."
 
Upvote 0

Forum statistics

Threads
1,223,905
Messages
6,175,297
Members
452,633
Latest member
DougMo

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top