You are here:

Visual Basic/VB6 programming


So many thanks to you for your advice, it is very helpful to me but at present I have a problem,

When the form loading then a message will display on the form,


then Username & Password given by the user for signin. After submission, the system will verify the given name & password are present in the mdb file. If the system not found then a message will display "Do you want to register yourself?-Yes/No/Cancel" if the system matched the given name with the database then the next form will open for further processing otherwise the present form will be closed.

Please sir help me for another time to overcome the problem.

Thanks in advance.

have a form with 3 text boxes 3 labels and 4 buttons.
labels text Username,Password,Retype Password
textboxes txtUsername,txtPassword,txtRepPass .the last two to have passwordchar prop as *

for command buttons, ok, cancel, new user, exit

this is the code:

Option Explicit
put check mark on project_references,Microsoft ActiveX dataobjects2.8
Dim conn As ADODB.Connection, rec As ADODB.Recordset, esql As String, LoggedUser As String, rec1 As ADODB.Recordset
Dim loginSucceded As Boolean
Private Sub FormLoad()
Set conn = New ADODB.Connection
Set rec = New ADODB.Recordset
Set rec1 = New ADODB.Recordset

conn.Open ("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "Login.mdb;Persist Security Info=False")
'put the mdb file  in same directory as the vb project file. it must have fields user name, password
'change the path
End Sub

Private Sub cmdCancel_Click()
       loginSucceded = False
End Sub

Private Sub cmdOK_Click()
 If txtUserName.Text = "" Or txtPassword = "" Then Exit Sub
If tRepPass.Text <> txtPassword.Text Then
MsgBox ("Passwords don't  match")
Exit Sub
End If
 esql = "select * from Users where Username=" & "'" & txtUserName & "'"
 esql = esql & " And password=" & "'" & txtPassword & "'"
 rec.Open (esql), conn, adOpenStatic, adLockReadOnly
 If rec.RecordCount > 0 Then
LoggedUser = txtUserName.Text
 MsgBox ("Now you are Logged in")
Unload Me
 'here put the form you want to open like form1.visible=true
     MsgBox "Invalid Password, try again!", , "Login"
       SendKeys "{Home}+{End}"
End If
End Sub

Private Sub Command1_Click()
Unload Me
flogin.Visible = True

End Sub

Private Sub Command2_Click()
End Sub

' have to check out the code and correct errors if any. have not tested the code
Ravindra MG

Visual Basic

All Answers

Answers by Expert:

Ask Experts




visual basic application programming from design to access information, sql, engineering and commercial applications. access databases, excel.(VB6) basic questions in vb 2008. Optional: 1)a large number of people want me to do work which takes some time and effort. can do projects in vb 2008. Pl.note that i would like to be paid for such work. 2) if you want me to spend quality time and do special work, i expect to be paid a reasonable price for my time. 3) if you are pleased with my reply you could consider a good amount. 4) you can visit my website


programming since the past 15 years. have completed a large number of projects in Industrial applications, finance,accounts, correspondence. excel macros etc

engineering, management degrees.

Past/Present Clients
project work for a Norway company,USA company and a Canadian company completed. Freelance Project work and Teaching. helping programmers with their work
teaching vb

©2017 All rights reserved.