473,320 Members | 2,097 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

Compare and Return Record

1
Hi, I understand that MS Access is not really meant for multi-users if robust security is the ultimate concern...but I'm trying to create a work-around where a user logs in and is prompted to enter two parameters to pull up their individual record. For example, they would put in an ID number and a Password...these two parameters are used to lookup in a table the exact record that matches both the ID number and password and returns information associated with that record.

Can someone help get me started on the VBA code that would do that?

So, the user would enter an ID Number and a Password in a form, then click a button to retrieve specific fields for 1 record in the table that matches.

Thanks!
Feb 13 '08 #1
2 1292
jaishu
22
For creating a form, you can goto Design view in form and create your own text boxes(assuming you are new to Ms Access) and other controls , and on right click of each control you have properties events associated, you can chose on which event, you want to associate controls to, eg, ; on CLICK of a command button..please see below code, i did this for a login screen,
Where user enters, both username and password to goto next screen.(putall that info in a table)
I have just given an example - i have used Username selection in combobox rather than textbox,.hope this helps..

[code goes here]....

Private Sub Form_Load()
Dim a As Integer
DBconnect

a = Combobox.ListCount
Do Until a = 0
Combobox.RemoveItem (a - 1)
a = a - 1
Loop
rs.Open "SELECT NAME,PASSWORD FROM LOGIN_TEST ", Cnt, adOpenKeyset, adLockOptimistic
Do Until rs.EOF
Combobox.AddItem (rs("NAME"))
rs.MoveNext
Loop
rs.Close

End Sub

Private Sub enter_click()
On Error GoTo ErrorHandler


'Check to see if data is entered into the UserName combo box
If IsNull(Combobox) Or Me.Combobox = "" Then
MsgBox "You must select a User Name.", vbOKOnly, "Required Data"
Me.Combobox.SetFocus
Exit Sub
End If

'Check to see if data is entered into the Passcode box

'If IsNull(Text6.Value) Or Text6 = "" Then
' MsgBox "You must enter a Password.", vbOKOnly, "Required Data"
' Me.Text6.SetFocus
' Exit Sub
'End If

'Check value of Passcode in Table login_test1 to see if this
'matches value chosen in combo box

querylogin = "select * from login_test where name='" & Combobox & "' and password = ' "& Text6 &"'"
rs.Open querylogin, Cnt, adOpenStatic, adLockOptimistic
If Not rs.EOF Then
'Close logon form and open Menu screen
User1 = Combobox
DoCmd.Close acForm, "loginscreen_test1", acSaveNo
DoCmd.OpenForm "MAIN_MENU"

Else
'If User Enters incorrect Password more than 3 times Application will close
intLogonAttempts = intLogonAttempts + 1
If intLogonAttempts >= 4 Then
MsgBox "You have exceeded the number of attempts,Application will exit", _
'vbCritical, "Restricted Access!"

Application.Quit

End
Else

MsgBox "Passcode Invalid. Please Try Again", vbOKOnly, "Invalid Entry!"
Me.Text6.SetFocus

End If
End If
rs.Close
ErrorHandlerExit:
Exit Sub
ErrorHandler:
If Err.Number = 2001 Then
Resume Next
Else
MsgBox "Error No: " & Err.Number & "; Description: " & Err.Description
Resume ErrorHandlerExit
End If
End Sub

[Code ends here]
Feb 13 '08 #2
MindBender77
234 100+
So, the user would enter an ID Number and a Password in a form, then click a button to retrieve specific fields for 1 record in the table that matches.

Thanks!
How were you going to display their specific data?

This could be done using a subform were the record source is a query that selects user data where the criteria is their ID Number and Password that was enter on the Main Form.

Hope this Points you in the right directions,
Bender
Feb 13 '08 #3

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

Similar topics

4
by: Gleep | last post by:
Hey Guys, I've got a table called Outcomes. With 3 columns and 15 rows 1st col 2nd col 3rdcol outcome date price There are 15 rows...
9
by: Gleep | last post by:
sorry i didn't explain it correctly before my table is like this example fields: ID name username outcome date1 date2 date3 (etc..) - date15 price1 price2 price3 (etc..) I know that...
13
by: MrCoder | last post by:
Hey guys, my first post on here so I'll just say "Hello everbody!" Ok heres my question for you lot. Is there a faster way to compare 1 byte array to another? This is my current code //...
9
by: Rich | last post by:
Thanks for the Help in my previous post. I've been working on this and it's almost what I want. I want to obtain the user's current age by comparing their date of birth (user inputs) to the...
5
by: Megan | last post by:
Hi everybody- I'm helping a friend with a music database. She has an old one and is creating a new one. She wants to compare records and fields in the old database with records and fields in the...
19
by: David zhu | last post by:
I've got different result when comparing two strings using "==" and string.Compare(). The two strings seems to have same value "1202002" in the quick watch, and both have the same length 7 which I...
5
by: rcolby | last post by:
Evening, Wondering if someone can point me in the right direction, on how I would compare a system.guid with a system.byte. system.guid (pulled from sql server table with a data type of...
0
by: Peter Wang | last post by:
I have a function and am using cursor. All the columns I select in the cursor clause are BYTEA datatype. I need to compare the after-fetch-value for two BYTEA columns which is temp2 and temp3...
1
by: amanda | last post by:
What will be the syntax if I want to compare whether the phone number I am entering when adding a record already exists in database. The phone field in that table is set to primary key. We are...
5
by: =?Utf-8?B?c2lwcHl1Y29ubg==?= | last post by:
Hi I have a Container that is an an Array List of Class Each ArrayList element can be the class or a another ArrayList of Class So there the ArrayList could look like Element 1 - Class...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.