| | |
accessing ms access from VB
Please support our Visual Basic 4 / 5 / 6 advertiser: Programming Forums - DaniWeb Sister Site
![]() |
A conclusion is the place where you got tired of thinking. http://www.martin2k.co.uk/forums/index.php?showforum=4
http://www.a1vbcode.com/a1vbcode/vbforums/Forum3-1.aspx
http://www.developerfusion.co.uk/for...orum&ForumID=4
yes,quite but now im facing another problem.. i tried using loops to check whether Reservation made by customer have been occupied before saving the record,so i used these..
but it never work..do u have any idea how?
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
Private Sub CmdSave_Click() Adodc1.Recordset.MoveFirst Do While Not Adodc1.Recordset.EOF If Adodc1.Recordset.Fields("Reserv_Date").Value = Txt_Date.Text And Adodc1.Recordset.Fields("Booking_Time").Value = Txt_Time.Text And Adodc1.Recordset.Fields("Fac_Type").Value = Cmb_Type.Text Then Txt_Date.Text = "" Txt_Time.Text = "" Txt_Date.SetFocus DisableButtons CmdSave.Enabled = True CmdAddNew.Caption = "&Cancel" MsgBox "Reservation occupied! Please choose another date and time", vbOKOnly Exit Sub End If Adodc1.Recordset.MoveNext Loop Adodc1.Recordset.Requery If Adodc1.Recordset.Fields("Reserv_Date").Value <> Txt_Date.Text And Adodc1.Recordset.Fields("Booking_Time").Value <> Txt_Time.Text And Adodc1.Recordset.Fields("Fac_Type").Value = Cmb_Type.Text Then Adodc1.Recordset.Update EnableButtons CmdSave.Enabled = False CmdAddNew.Caption = "&Add New" MsgBox "Records are succesfully saved!", vbOKOnly End If End Sub
but it never work..do u have any idea how?
try this one hope it would work because I've never use adodc...
Function savecheck() As Boolean Dim rs as recordset for adodb sorry I don't know how savecheck = True Set rs= open the recordset for that table ... the query in your rs must be like this "select * from [tablename] where Reserv_Date+Booking_Time+Fac_Type = '" & Txt_Date.Text + Txt_Time.Text + Cmb_Type.Text & "'" if Not rs.Eof then savecheck=False Msgbox "Already occupied!" Exit Function End if End If Private Sub CmdSave_Click() If savecheck Then put your code here that will save your data entry End if Ens Sub
A conclusion is the place where you got tired of thinking. http://www.martin2k.co.uk/forums/index.php?showforum=4
http://www.a1vbcode.com/a1vbcode/vbforums/Forum3-1.aspx
http://www.developerfusion.co.uk/for...orum&ForumID=4
hi there jireh..
i tried blending in your codes with the use of adodc but it nvr seem to work..i found the logic of your codes appropriate for my program but i just dont know how to make a query with the use of adodc..it seems that adodc simplifies the steps in connecting from vb to database(everything is almost auto)but i still cant figure out a way.i know you never use adodc before but if you happen to have any idea on resolving my problem please send feedbacks k..thanx so much
i tried blending in your codes with the use of adodc but it nvr seem to work..i found the logic of your codes appropriate for my program but i just dont know how to make a query with the use of adodc..it seems that adodc simplifies the steps in connecting from vb to database(everything is almost auto)but i still cant figure out a way.i know you never use adodc before but if you happen to have any idea on resolving my problem please send feedbacks k..thanx so much
•
•
Join Date: May 2008
Posts: 2
Reputation:
Solved Threads: 0
•
•
•
•
hi....i m actually developing a tool which uses access as the database source...i hv created 2 coloumns in the database....username and password....now in my tool i need to ask the user fr his username and password....if it matches with any of the combinations stored in the database then the user can login ....cn anyone help me wiith dis ....
like this way: if rs is recordset then code will be like---------
rs.open("select * from tbluser where loginname = '" & txtlogin.text & "' and password = '" & txtpassword.text & "'"),cn
if rs.recordcount > 0 then
''' login successfully
else
''' cant login
end if
----- try this code with your table name and column name....
•
•
Join Date: Dec 2008
Posts: 21
Reputation:
Solved Threads: 0
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
option Explicit Private Sub cmdAccept_Click() Dim cn As New ADODB.Connection Dim strCNString As String Dim rs As New ADODB.Recordset Dim Txt As String On Error GoTo ErrHandler 'Connect to database strCNString = "Data Source=" & App.Path & "\databasename.mdb" cn.Provider = "Microsoft Jet 4.0 OLE DB Provider" cn.ConnectionString = strCNString cn.Properties("Jet OLEDB:Database Password") = "" cn.Open 'Open recordsource With rs .Open "Select * from tablename where name='" & txtName.Text & "' and Password='" & txtPassword.Text & "'", cn, adOpenDynamic, adLockOptimistic 'Check username and password If .EOF Then MsgBox "Access Denied...Password and name do not match,Please enter correct Details!", vbOKOnly + vbCritical, "Security Login" txtName.Text = "" txtPassword.Text = "" txtName.SetFocus cn.Close Else Txt = "" & " " & UCase$(txtName.Text) & "" MsgBox "Welcome!!!" & Txt, vbOKOnly + vbExclamation, "Security Login" cn.Close Unload Me frmform2.Show End If End With ExitHere: Exit Sub ErrHandler: MsgBox Err.Number & " " & Err.Description, vbCritical, "Login ..." cn.Close End Sub Private Sub Form_Load() txtPassword.PasswordChar = "*" End Sub
Last edited by Ancient Dragon; Jan 13th, 2009 at 10:55 am. Reason: add code tags
![]() |
Similar Threads
- Private Access (C++)
- Accessing an Access Database using Java (Java)
- Begin transaction in VB? (Visual Basic 4 / 5 / 6)
- problems with recordset accessing access (Visual Basic 4 / 5 / 6)
Other Threads in the Visual Basic 4 / 5 / 6 Forum
- Previous Thread: Trying to create a Simple AIO need help!
- Next Thread: vb6 help needed for bill printing
| Thread Tools | Search this Thread |
* 6 429 2007 access activex add age append application basic beginner birth bmp calculator cd cells.find click client code college column component connection connectionproblemusingvb6usingoledb copy creat ctrl+f data database datareport date delete dissertations dissertationthesis dissertationtopic edit error excel excelmacro file filename form hardware header iamthwee image inboxinvb internetfiledownload keypress label listbox listview liveperson login looping machine microsoft movingranges number objectinsert open oracle password prime program prompt range-objects readfile reading record refresh remotesqlserverdatabase report retrieve save search sendbyte sites sort sql sql2008 sqlserver subroutine table tags textbox time urldownloadtofile vb vb6 vb6.0 vba visual visualbasic visualbasic6 web window windows





