943,800 Members | Top Members by Rank

Ad:
You are currently viewing page 2 of this multi-page discussion thread; Jump to the first page
Jul 26th, 2007
0

Re: accessing ms access from VB

yes. infact that was my main mistake!ive tried other methods as well..thanx for reminding me bout that,jireh..
Reputation Points: 10
Solved Threads: 0
Newbie Poster
rumi is offline Offline
6 posts
since Jul 2007
Jul 26th, 2007
0

Re: accessing ms access from VB

Click to Expand / Collapse  Quote originally posted by rumi ...
yes. infact that was my main mistake!ive tried other methods as well..thanx for reminding me bout that,jireh..
So does your problem is solved?
Reputation Points: 11
Solved Threads: 49
Posting Whiz
jireh is offline Offline
316 posts
since Jul 2007
Jul 27th, 2007
0

Re: accessing ms access from VB

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..
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
  1. Private Sub CmdSave_Click()
  2. Adodc1.Recordset.MoveFirst
  3. Do While Not Adodc1.Recordset.EOF
  4. 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
  5. Txt_Date.Text = ""
  6. Txt_Time.Text = ""
  7. Txt_Date.SetFocus
  8. DisableButtons
  9. CmdSave.Enabled = True
  10. CmdAddNew.Caption = "&Cancel"
  11. MsgBox "Reservation occupied! Please choose another date and time", vbOKOnly
  12. Exit Sub
  13. End If
  14. Adodc1.Recordset.MoveNext
  15. Loop
  16. Adodc1.Recordset.Requery
  17. 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
  18. Adodc1.Recordset.Update
  19. EnableButtons
  20. CmdSave.Enabled = False
  21. CmdAddNew.Caption = "&Add New"
  22. MsgBox "Records are succesfully saved!", vbOKOnly
  23. End If
  24. End Sub

but it never work..do u have any idea how?
Reputation Points: 10
Solved Threads: 0
Newbie Poster
rumi is offline Offline
6 posts
since Jul 2007
Jul 27th, 2007
0

Re: accessing ms access from VB

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
Reputation Points: 11
Solved Threads: 49
Posting Whiz
jireh is offline Offline
316 posts
since Jul 2007
Jul 29th, 2007
0

Re: accessing ms access from VB

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
Reputation Points: 10
Solved Threads: 0
Newbie Poster
rumi is offline Offline
6 posts
since Jul 2007
May 1st, 2008
0

Re: accessing ms access from VB

How do i access only a column from MS access to VB?
I am also newbie on VB.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
elleinad is offline Offline
3 posts
since May 2008
May 2nd, 2008
0

Re: accessing ms access from VB

Click to Expand / Collapse  Quote originally posted by anud18 ...
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 ....
First create Connectivity with your database with DAta control or ADODC control or by ADODB . If you are useing ADODB connection then create recordset to access your table and then compare all values of ur table with username and password given by user.
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....
Reputation Points: 10
Solved Threads: 0
Newbie Poster
roshani285 is offline Offline
2 posts
since May 2008
Jan 13th, 2009
0

Re: accessing ms access from VB

Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
  1. option Explicit
  2.  
  3. Private Sub cmdAccept_Click()
  4. Dim cn As New ADODB.Connection
  5. Dim strCNString As String
  6. Dim rs As New ADODB.Recordset
  7. Dim Txt As String
  8.  
  9. On Error GoTo ErrHandler
  10. 'Connect to database
  11. strCNString = "Data Source=" & App.Path & "\databasename.mdb"
  12. cn.Provider = "Microsoft Jet 4.0 OLE DB Provider"
  13. cn.ConnectionString = strCNString
  14. cn.Properties("Jet OLEDB:Database Password") = ""
  15. cn.Open
  16. 'Open recordsource
  17. With rs
  18. .Open "Select * from tablename where name='" & txtName.Text & "' and Password='" & txtPassword.Text & "'", cn, adOpenDynamic, adLockOptimistic
  19. 'Check username and password
  20. If .EOF Then
  21. MsgBox "Access Denied...Password and name do not match,Please enter correct Details!", vbOKOnly + vbCritical, "Security Login"
  22. txtName.Text = ""
  23. txtPassword.Text = ""
  24. txtName.SetFocus
  25. cn.Close
  26. Else
  27. Txt = "" & " " & UCase$(txtName.Text) & ""
  28. MsgBox "Welcome!!!" & Txt, vbOKOnly + vbExclamation, "Security Login"
  29.  
  30. cn.Close
  31. Unload Me
  32. frmform2.Show
  33.  
  34. End If
  35. End With
  36.  
  37. ExitHere:
  38. Exit Sub
  39.  
  40. ErrHandler:
  41. MsgBox Err.Number & " " & Err.Description, vbCritical, "Login ..."
  42. cn.Close
  43. End Sub
  44.  
  45. Private Sub Form_Load()
  46. txtPassword.PasswordChar = "*"
  47.  
  48. End Sub
Last edited by Ancient Dragon; Jan 13th, 2009 at 10:55 am. Reason: add code tags
Reputation Points: 10
Solved Threads: 0
Light Poster
sackymatt is offline Offline
29 posts
since Dec 2008
Jan 13th, 2009
0

Re: accessing ms access from VB

hope that code helps u anud
Reputation Points: 10
Solved Threads: 0
Light Poster
sackymatt is offline Offline
29 posts
since Dec 2008

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Visual Basic 4 / 5 / 6 Forum Timeline: Trying to create a Simple AIO need help!
Next Thread in Visual Basic 4 / 5 / 6 Forum Timeline: vb6 help needed for bill printing





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC