Vous êtes sur la page 1sur 6

Using Security TABLE in CWP1.

accdb file we have to login in to the home Page of project

As

Private Sub cmdok_Click()

Set rs = conn.Execute("select * from securityTbl where UserName='" & txtusername.Text & "' and
Password='" & txtpassword.Text & "'")

If Not rs.EOF Then

frmLogin.Hide

MDIForm1.Show

'MDIFormmainmenu.StatusBar1.Panels(3) = "Currently Login: " + rs!UserName

Else

MsgBox "Access Denied", vbCritical, "Confirmation"

txtusername.Text = ""

txtpassword.Text = ""

End If

End Sub

Private Sub Form_Load()

conn.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data
Source=C:\Users\tml\Desktop\purnima\projects\Cwpproj\CWP1.accdb;Persist Security Info=False"

conn.Open

End Sub
Option Explicit

Dim cn As New ADODB.Connection

Dim rs As New ADODB.Recordset

Dim toggle As Integer

Dim sql As String

Dim X As Variant

Private Sub cmdA_Click()

If txtPrtn.Text = "" Or txtPd = "" Or txtQty = "0" Or txtQty = "00" Or txtQty = "000" Or txtQty = "0000" Or
txtQty = "" Then

MsgBox "All Fields Required or Select proper quantity", vbRetryCancel

Else

MsgBox "your record has been added successfully", vbInformation

Adodc1.Recordset.AddNew

End If

End Sub

Private Sub cmdReset_Click()

txtPrtn = ""

txtQty = ""
txtPd = ""

End Sub

Private Sub Command1_Click()

MDIForm1.Show

End Sub

Private Sub Form_Load()

Adodc1.Recordset.AddNew

DTPicker1.Value = Now

'DTPicker1.Refresh

End Sub

Private Sub Timer1_Timer()

lblDate.Caption = Format$(Now, "dd mmmm yyyy hh:nn:ss AM/PM")

End Sub

Option Explicit
Dim conn As New ADODB.Connection

Dim rs As New ADODB.Recordset

Dim toggle As Integer

Dim sql As String

Dim X As Variant

Private Sub txtclear()

txtPno.Text = ""

txtPname.Text = ""

txtquantity.Text = ""

TXTID.Text = ""

Text1.Text = ""

txtNeedQ.Text = ""

End Sub

Private Sub cmdaddP_Click()

Set conn = New ADODB.Connection

Set rs = New ADODB.Recordset

Dim QTY As Integer

Dim i As Integer

Dim sql1, sql2 As String

conn.Open (Adodc1.ConnectionString)

sql1 = "INSERT INTO sales_Record(Part_No,PART_Name,Qty,Dated_on)values('" & txtPno.Text & "','" &


txtPname.Text & "','" & txtNeedQ.Text & "','" & lblD.Caption & "')"

conn.Execute (sql1)

MsgBox "Sale Record has been saved", vbInformation, "Confirmation"


sql2 = "UPDATE cwpAdd_DATA SET Quantity= Quantity-'" & txtNeedQ.Text & "' where Part_No= '" &
txtPno.Text & "'"

'If txtquantity.Text <= 5 Then

'MsgBox (" stock level is less than 5")

'End If

conn.Execute (sql2)

Adodc1.Refresh

'conn.Close

'MsgBox (" stock level is low")

Call txtclear

End Sub

Private Sub cmdfindbysalesret_Click()

'txtPno.Text = Text1.Text

Set rs = conn.Execute("select * from cwpAdd_DATA where Part_No='" & txtPno.Text & "'")

If Not rs.EOF Then

txtquantity.Text = rs!Quantity

TXTID.Text = rs!ID

txtPno.Text = rs!Part_No

Text1.Text = rs!Part_No

txtPname.Text = rs!PART_Name

txtDate.Text = rs!Dated_on

Else

MsgBox "No Result found!", vbExclamation, "Confirmation"

End If

End Sub
‘’How to insert data in to the combobox from the ms access mdb file.
Adodc1.Refresh
Adodc1.Recordset.MoveFirst
Do While Not Adodc1.Recordset.EOF
Combo_Partn.AddItem Adodc1.Recordset.Fields("PartNO")
‘’cboPname.AddItem Adodc1.Recordset.Fields("PART Name")
Adodc1.Recordset.MoveNext
Loop

Vous aimerez peut-être aussi