Anine 0 Newbie Poster

I am working on a login password. I want my front page to load and then the password form to appear. The user then types in userid and password - if correct the login form closes. I want the front page to remain visible behind the login form BUT - I dont want the user to be able to use any buttons on the Front Page until after login is complete.

I have the Front Page Enabled = False at Load. I want it to go to Enable = True after Login is complete. I want to pass the change in Enable from my login form to my front page form. (can it be done?)

I am getting an error (I have tried using .focus and get the same error )

An unhandled exception of type 'System.NullReferenceException' occurred in WindowsApplication1.exe

Additional information: Object reference not set to an instance of an object.
(*** = where error is occuring)

login form

Public Class frmMgtLogin
Inherits System.Windows.Forms.Form

Dim UP As New OleDb.OleDbCommand
Dim Con As New OleDb.OleDbConnection
Dim Read As OleDb.OleDbDataReader
Dim Plus As Integer
Public CurrentForm As System.Windows.Forms.Form

Private Sub btnSubmit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSubmit.Click
If txtUserName.Text.Trim = "" Then
MessageBox.Show("Please fill your User Name !", _
"Password", MessageBoxButtons.OK, _
MessageBoxIcon.Exclamation)
txtUserName.Focus()
Exit Sub
End If

'if textbox2 is blank then ...
If txtPassword.Text.Trim = "" Then
MessageBox.Show("Please fill your Password !", _
"Password", MessageBoxButtons.OK, _
MessageBoxIcon.Exclamation)
txtPassword.Focus()
Exit Sub
End If

'Admin
UP.Parameters.Add("user", Data.OleDb.OleDbType.Variant)
UP.Parameters.Add("password", Data.OleDb.OleDbType.Variant)

UP.Parameters("user").Value = txtUserName.Text
UP.Parameters("password").Value = txtPassword.Text


'Open database connection
Con.Open()

' Read information from database
Read = UP.ExecuteReader

ar()

' Close database connection
Con.Close()

End Sub

Private Sub ar()
With Read
If .Read Then
Me.Close()
Dim CurrentForm As FrontPage
*** CurrentForm.Enabled = True
CurrentForm.Show()

Else
Plus += 1

If Plus >= 3 Then
MessageBox.Show("Sorry, too many error !", _
"Password", MessageBoxButtons.OK, _
MessageBoxIcon.Exclamation)
'Close application
End
Else

txtUserName.Clear()
txtPassword.Clear()


MessageBox.Show("Invalid User Name or Password !", _
"Password", MessageBoxButtons.OK, _
MessageBoxIcon.Error)
End If
End If
txtUserName.Focus()
End With
End Sub

Private Sub frmMgtLogin_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'Connection string
'Con.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Replace(Application.StartupPath, "bin", "") & "Pas.mdb;Mode=ReadWrite;Persist Security Info=False"

Con.ConnectionString = "Jet OLEDB:Global Partial Bulk Ops=2;Jet OLEDB:Registry Path=;Jet OLEDB:Database L" & _
"ocking Mode=1;Data Source=""C:\Documents and Settings\Owner\My Documents\Visual S" & _
"tudio Projects\WindowsApplication1\ConsignmentShop.mdb"";Mode=Share Deny None;Jet" & _
" OLEDB:Engine Type=5;Provider=""Microsoft.Jet.OLEDB.4.0"";Jet OLEDB:System databas" & _
"e=;Jet OLEDB:SFP=False;persist security info=False;Extended Properties=;Jet OLED" & _
"B:Compact Without Replica Repair=False;Jet OLEDB:Encrypt Database=False;Jet OLED" & _
"B:Create System Database=False;Jet OLEDB:Don't Copy Locale on Compact=False;User" & _
" ID=Admin;Jet OLEDB:Global Bulk Transactions=1"

UP.Connection = Con
UP.CommandType = CommandType.Text
UP.CommandText = "Select * From UserLogin Where UserID =? and PassID =?"


End Sub


End Class