 |
JLRodgers Level: Moderator
 Registered: 04-04-2002 Posts: 1617
|
Re: vb6 HELP! Barcode scanner then msaccess Archived to Disk
Just trying to clarify, you just need to know how to compare a student ID to a list of valid IDs, then verify a password?
If so, then the easiest way is to open the table with a "SELECT * FROM [Students] WHERE SID='" & txtStudentID.Text & "'"
if data exists (valid id), then you'd have a record, if not valid, no records.
|
|
23-05-2002 at 06:40 PM |
|
|
JLRodgers Level: Moderator
 Registered: 04-04-2002 Posts: 1617
|
Re: vb6 HELP! Barcode scanner then msaccess Archived to Disk
Without a form at startup, you can put it in a module. Of course, I dont' know how the scanner passes the info to programs, probably a dll or something, but you'd have to retrieve it, and put in in the specified place.
It'd be something like:
Private sub Main()
Dim adc as new ADODB.Connection
Dim ars as new ADODB.Recordset
Set adc = new ADODB.Connection
Set ars = new ADODB.Recordset
adc.Open '"Connection string, add a ADO control, create the connection string for it, then paste it here, delete the control"
ars.Open "SELECT * FROM [Students] WHERE SID='" & HoweverGetIDFromScanner & "'"
If not ars.BOF and not ars.EOF then
frmVerify.Show
End if
If ars.State = adStateOpen then ars.Close
If adc.State = adStateOpen then adc.Close
Set ars = Nothing
Set adc = Nothing
End Sub
|
|
24-05-2002 at 03:40 PM |
|
|
mike Level: Trainee
 Registered: 20-03-2006
|
Re: Re: vb6 HELP! Barcode scanner then msaccess Archived to Disk
Hi! where will i put the source code? in the form? i or module? the barcode is plug and play type. when you scan a barcode, the decoded number will be placed where the cursor is. I think i can put an invisible text box and place the decoded number there. but the problem is how will i verify it in my database eventhough the user doesn't press the keyborad or doesn't click the mouse?
|
|
26-05-2002 at 01:48 PM |
|
|
JLRodgers Level: Moderator
 Registered: 04-04-2002 Posts: 1617
|
Re: vb6 HELP! Barcode scanner then msaccess Archived to Disk
I believe the textbox will have to be visible to put stuff in it, but I'd do the following with it:
Text1.Enabled=True
Text1.Visible=True
Text1.Locked=True
Text1.BackColor=vbButtonFace 'Make it look disabled
Text1.TabStop=False
Text1.SetFocus (at the form's startup, that way the cursor will always be there when loading, make sure form is visible first, otherwise an error will occur)
Then, have the following
Private Sub Text1_Change()
' Put the code here for verifying the barcode
' However, you may need to check the length first...
'IE:
If len(Text1.Text)>=10 then
' Code to verify
End If
End Sub
|
|
26-05-2002 at 09:19 PM |
|
|
JLRodgers Level: Moderator
 Registered: 04-04-2002 Posts: 1617
|
Re: vb6 HELP! Barcode scanner then msaccess Archived to Disk
It's somewhat long, and would require testing on your side (that can't be done without the scanner!) and of course, the database name, connection string would have to be modified; as would the field names, but the following is "complete":
' ---- START Module ----
Private adc As New ADODB.Connection
Private ars As New ADODB.Recordset
Option Explicit
Private Sub Main()
Init
frmMain.Show
End Sub
Private Sub Init()
Set adc = New ADODB.Connection
Set ars = New ADODB.Recordset
'Connections, although locations, names change based on your format
'SQL
' adc.Open "Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=StudentsID;Data Source=(local)"
'Access
adc.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=StudentID;Persist Security Info=False"
End Sub
Private Sub DeInit()
If ars.State = adStateOpen Then ars.Close
If adc.State = adStateOpen Then adc.Close
Set ars = Nothing
Set adc = Nothing
End Sub
Public Sub Verify(ByVal BarCode As String)
If ars.State = adStateOpen Then ars.Close
ars.Open "SELECT * FROM [Students] WHERE SID='" & BarCode & "'", adc, adOpenStatic, adLockReadOnly
If Not ars.BOF And Not ars.EOF Then
'Verify Student Password
With frmPWD
.Show
.lblSID = BarCode
.lblStudentName = ars.Fields("StudentName")
End With
End If
End Sub
Public Function VerifyPassword(ByVal SID As String, ByVal PWD As String) As Boolean
If ars.State = adStateOpen Then ars.Close
ars.Open "SELECT * FROM [Students] WHERE SID='" & SID & "' AND PWD='" & PWD & "'"
If Not ars.BOF And Not ars.EOF Then
VerifyPassword = True
Else
VerifyPassword = False
End If
End Function
'---- END Module ----
'---- START frmMain ----
'References:
' Microsoft ActiveX Data Objects 2.x (x is any number, higher->newer)
' 1-Textbox txtBarCode
'Startp: Sub Main
Option Explicit
Private Sub Form_Load()
Me.Visible = True
DoEvents
With txtBarCode
.Enabled = True
.Visible = True
.Locked = True
.BackColor = vbButtonFace 'Make look disabled
.TabIndex = 0
.TabStop = True
.SetFocus
End With
End Sub
Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
DeInit
End Sub
Private Sub txtBarCode_Change()
'If a student ID is a min of a certain length, put it here
'IE (for SSN, no dashes):
If Len(Trim(txtBarCode.Text)) >= 9 Then
Verify Trim(txtBarCode.Text)
End If
End Sub
'---- END frmMain ----
'---- START frmPWD ----
' Set Borderstyle to 4-Fixed ToolWindow
' Two labels, 1 for Name, 1 for ID
' One command button
' one textbox (password char *, although not needed see code)
Private strPassword As String
Option Explicit
Private Sub cmdOK_Click()
If VerifyPassword(lblSID.Caption, txtPWD.Text) Then
MsgBox "Valid"
Else
MsgBox "Invalid"
End If
' Didn't specify what to do from here
Unload Me
End Sub
Private Sub Form_Load()
End Sub
Private Sub txtPWD_KeyPress(KeyAscii As Integer)
' Since there's programs to see the hidden passwords... store the info into a variable, put *'s in the text box
' this way all the programs can "steal" are the *'s
If KeyAscii <> 8 And KeyAscii <> 13 Then
strPassword = strPassword & Chr(KeyAscii)
ElseIf KeyAscii = 8 Then
strPassword = Left(strPassword, Len(strPassword) - 1)
End If
KeyAscii = Asc("*")
End Sub
'---- END frmPWD ----
|
|
27-05-2002 at 05:54 PM |
|
|
mike Level: Trainee
 Registered: 20-03-2006
|
Re: Re: vb6 HELP! Barcode scanner then msaccess Archived to Disk
hi jL, there is an error in the program, maybe the i missed place some of them.
if i scan an i.d the program doesn't check the database and load the next form.
this is the error when i end the program
sub or function not defined
then
private sub_queryunload(....) is highlighted
Q?
1. what is the name of the database in your program? so i can change it, the name of my database is db1, the table containing the id number, name, and password is called tableEL.
2. if i double click a component, ex. textbox, form, command. where will i put the code under
Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
sub or function not defined.
private sub_queryunload(....) is highlighted
thnx!!
|
|
28-05-2002 at 04:19 PM |
|
|
JLRodgers Level: Moderator
 Registered: 04-04-2002 Posts: 1617
|
Re: vb6 HELP! Barcode scanner then msaccess Archived to Disk
In sub Init:
DB Name is: StudentID
In Verify Routines:
Table name is: [Students]
so just change those to what you need (IE: [tableEL] instead of [Students])
change: Private Sub DeInit() to Public Sub DeInit()
since I didn't have anything to "start" the program with, I never got the error, I always bypassed it.
|
|
28-05-2002 at 05:08 PM |
|
|
mike Level: Trainee
 Registered: 20-03-2006
|
Re: vb6 HELP! Barcode scanner then msaccess Archived to Disk
hi jL, i made all the necessary changes but the program still doesn't work. the program doesn't have any errors but it's not working well. the program is not(i think) checking the database and if it does, it does not show the second form that contain the name id number and textbox for password. PLS HElP.
|
|
29-05-2002 at 01:05 PM |
|
|
JLRodgers Level: Moderator
 Registered: 04-04-2002 Posts: 1617
|
Re: vb6 HELP! Barcode scanner then msaccess Archived to Disk
Set a break point in the:
Private Sub txtBarCode_Change()
to see if it's run. If it's not, check to make sure that the number is displayed in the text field when you scan, and that the text box is named txtBarCode. The cursor should be blinking in the form when it's run. When I inserted a numbers into the textbox, it ran.
Also, if the barcode will only be validated if the code is >=9, if the code is less than that, you'll need to change the following line for your case [in the txtBarCode_Change routine]
If Len(Trim(txtBarCode.Text)) >= 9 Then
Of course, it also assumes that the code you entered exists in the table, otherwise it won't load the second form. Set a breakpoint in the Verify routine.
Did you remember to change the SID= in the Verify routine to match the "Student ID number" field name? I'd believe so, since that would cause an error, but make sure.
----frmPWD Changes----
Also, in the frmPWD, in the cmdOK_Click change
VerifyPassword(lblSID.Caption, txtPWD.Text)
TO:
VerifyPassword(lblSID.Caption, strPassword)
AND add (just in case)
Private Sub Form_Load()
strPassword=""
End Sub
----End frmPWD Changes----
[Edited by JLRodgers on 29-05-2002 at 11:12 AM GMT]
|
|
29-05-2002 at 05:01 PM |
|
|
JLRodgers Level: Moderator
 Registered: 04-04-2002 Posts: 1617
|
Re: vb6 HELP! Barcode scanner then msaccess Archived to Disk
The text box is locked from user entering info, to allow users to enter info manually.
Change the following:
'---- START frmMain Modification----
Private Sub Form_Load()
Me.Visible = True
DoEvents
With txtBarCode
.Enabled = True
.Visible = True
.Locked = False 'FALSE=UserUditing, TRUE=NoUserEditing
.BackColor = vbButtonFace 'Make look disabled
.TabIndex = 0
.TabStop = True
.SetFocus
End With
End Sub
'----END frmMain Modification----
|
|
01-06-2002 at 05:04 PM |
|
|
mike Level: Trainee
 Registered: 20-03-2006
|
Re: Re: vb6 HELP! Barcode scanner then msaccess Archived to Disk
hi jl, the program has error Private Sub
Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
DeInit
End Sub
pls help. can't make your program run smoothly.
|
|
03-06-2002 at 02:28 PM |
|
|
JLRodgers Level: Moderator
 Registered: 04-04-2002 Posts: 1617
|
Re: vb6 HELP! Barcode scanner then msaccess Archived to Disk
If you changed the following line (like I had in a prior post), then I'm really confused (it's a standard VB form function).
change:
Private Sub DeInit() to Public Sub DeInit()
|
|
03-06-2002 at 04:34 PM |
|
|
mike Level: Trainee
 Registered: 20-03-2006
|
Re: vb6 HELP! Barcode scanner then msaccess Archived to Disk
Hi JL thanks a lot. Sorry if i replied quite late. about the program that you gave me, it's now working, i just got the help menu of my compiler last Saturday. It helps alot, just like you. thnx again!!!
|
|
10-06-2002 at 03:04 PM |
|
|
|
|
 |
 |