By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
425,705 Members | 1,891 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 425,705 IT Pros & Developers. It's quick & easy.

Making a fitness class booking after logging in as a user

P: 1
I have a booking page set up which shows the username field as well as Class type and Date

The issue I am having is that when I log in as a user, how do I automatically get the username field updated to that user which has logged in. So that the booking comes under their details. Can you guys share any coding to connect my login to automatically populate the username field. Or if there is an alternative way of making a booking whilst logged in, that would be great too.

This is my module

Expand|Select|Wrap|Line Numbers
  1. Option Compare Database
  3. Public CurrentUserID As String
  5. Public Function setUser(user123)
  6.     CurrentUserID = user123
  7. End Function
  9. Public Function deleteUser()
  10.     CurrentUserID = ""
  11. End Function
My login Code

Expand|Select|Wrap|Line Numbers
  1. Option Compare Database
  2. Option Explicit
  3. Private Sub btnLogin_Click()
  5. MemberID = Nz(DLookup("[MemberID]", "tblMember", "[Username] ='" & Me.txtUsername.Value & "' And password ='" & Me.txtPassword.Value & "'"), 0)
  6. If MemberID = 0 Then
  7.     MsgBox "Incorrect Username or Password"
  8.   Else
  9.     MsgBox "You have successfully logged in"
  10.     Call setUser(Me.txtUsername.Value)
  11.     DoCmd.OpenForm "frmHomepage"
  12.     End If
  13. End Sub
My homepage

Expand|Select|Wrap|Line Numbers
  1. Option Compare Database
  2. Public Sub btnBookings_Click()
  4.     DoCmd.OpenForm "frmBookings"
  6. End Sub
  8. Private Sub btnLogout_Click()
  10. Response = MsgBox("Are you sure you want to logout?", vbYesNo + vbQuestion, "Warning")
  11.    If Response = vbYes Then
  13.         Call deleteUser
  14.         DoCmd.Close
  15.         DoCmd.OpenForm "frmStart"
  16.     Exit Sub
  17.    End If
  19. End Sub
  21. Public Sub btnMembershipdetails_Click()
  23.     MsgBox (CurrentUserID)
  24.     'Copy Below to whereever you want member specific details
  25.     DoCmd.OpenForm "frmMemberDetails", , , "Username = '" & CurrentUserID & "'"
  27. End Sub
When I login as a user, I can load up their specific details through the module. I'm assuming it will require me doing something similar to get each user to make a booking when they login.
Mar 5 '18 #1
Share this Question
Share on Google+
2 Replies

Expert Mod 2.5K+
P: 3,205

Welcome to Bytes!

First, when posting code, please use the Code Tags button "[CODE/]" to have it properly formatted on this forum.

Second, I think a potential solution may be found in this Article:
How To Create User Permissions and Customized Menus in MS Access. If you have additional questions concerning that set-up, please let me know, I might be able to shep some light on it.

There are less-elaborate ways to do this, but the foundation is the same. Find out who the system user is and update your information based upon that user's information.

Hope that hepps!
Mar 5 '18 #2

Expert Mod 2.5K+
P: 3,205
Did the linked article provide any additional insight for you?
Mar 6 '18 #3

Post your reply

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