Reply

Join Date: Sep 2008
Posts: 3
Reputation: shilli is an unknown quantity at this point 
Solved Threads: 0
shilli shilli is offline Offline
Newbie Poster

ERROR in VB

 
0
  #1
Sep 27th, 2008
Hi,

I m making telephone directory using VB.For this i have taken code from net and made some changes in it.But after making changes i got an error unrecognised database format.
Plz anyone help me to remove this error.

Thanks in advance.
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 51
Reputation: Drycola is an unknown quantity at this point 
Solved Threads: 6
Drycola's Avatar
Drycola Drycola is offline Offline
Junior Poster in Training

Re: ERROR in VB

 
0
  #2
Sep 27th, 2008
Would you please show the part of the code that had errors??
Reply With Quote Quick reply to this message  
Join Date: Sep 2008
Posts: 3
Reputation: shilli is an unknown quantity at this point 
Solved Threads: 0
shilli shilli is offline Offline
Newbie Poster

Re: ERROR in VB

 
0
  #3
Sep 27th, 2008
I M SENDING U D WHOLE CODE U PLZ RUN IT N TELL WHTS D PROBLEM.
visualbasic Syntax (Toggle Plain Text)
  1. Option Explicit
  2.  
  3. Dim vID As String, vName As String, vAddress As String, vTelNum As String, vCity As String
  4.  
  5. Private Sub cmdCloseCancel_Click()
  6.  
  7. If cmdCloseCancel.Caption = "&Close" Then
  8. End
  9. Else
  10. Call Default_Obj
  11. End If
  12.  
  13. End Sub
  14.  
  15. Private Sub cmdDelete_Click()
  16.  
  17. Dim vI As Integer
  18.  
  19. If MsgBox("Are you sure you want to delete this entry?", vbQuestion + vbYesNo, "Confirm Delete") = vbYes Then
  20. With dtaDB
  21. .RecordSource = "SELECT * FROM DirectoryList WHERE ID='" & vID & "'"
  22. .Refresh
  23. With .Recordset
  24. If .BOF = False Then
  25. .Delete
  26. Call Default_Obj
  27. Call Show_Existing("SELECT * FROM DirectoryList")
  28. Else
  29. MsgBox "The record you want to delete doesn't exist.", vbExclamation, "Not Found"
  30. Exit Sub
  31. End If
  32. End With
  33. End With
  34. Else
  35. Exit Sub
  36. End If
  37.  
  38. End Sub
  39.  
  40. Private Sub cmdEditUpdate_Click()
  41.  
  42. If cmdEditUpdate.Caption = "&Edit" Then
  43. cmdEditUpdate.Caption = "&Update"
  44. fraSearch.Enabled = False
  45. fraInfo.Enabled = True
  46. FraBinfo.Enabled = True
  47. cmdCloseCancel.Caption = "&Cancel"
  48. vName = txtName
  49. vAddress = txtAddress
  50. vTelNum = txtTelNum
  51. vCity = txtCity
  52. txtName.SetFocus
  53. SendKeys "{HOME}+{END}"
  54.  
  55. Else
  56.  
  57. If Len(txtName) = 0 Then
  58. MsgBox "Full Name Textbox contains no data.", vbExclamation, "Empty Textbox"
  59. txtName.SetFocus
  60. Exit Sub
  61. End If
  62.  
  63. If Len(txtAddress) = 0 Then
  64. MsgBox " Address Textbox contains no data.", vbExclamation, "Empty Textbox"
  65. txtAddress.SetFocus
  66. Exit Sub
  67. End If
  68.  
  69. If Len(txtTelNum) = 0 Then
  70. MsgBox "Telephone # Textbox contains no data.", vbExclamation, "Empty Textbox"
  71. txtTelNum.SetFocus
  72. Exit Sub
  73. End If
  74.  
  75. If Len(txtCity) = 0 Then
  76. MsgBox "City Textbox contains no data.", vbExclamation, "Empty Textbox"
  77. txtCity.SetFocus
  78. Exit Sub
  79.  
  80. If vName = txtName And vAddress = txtAddress And vTelNum = txtTelNum And vCity = txtCity Then
  81. MsgBox "No changes was made in this record.", vbInformation, "Update Record"
  82. Call Default_Obj
  83. Exit Sub
  84. Else
  85. With dtaDB
  86. .RecordSource = "SELECT * FROM DirectoryList WHERE Name='" & txtName & "' AND Address='" & txtAddress & "' AND TelNum ='" & txtTelNum & "' AND City=' " & txtCity & " '"
  87. .Refresh
  88. With .Recordset
  89. If .BOF = True Then
  90. GoTo EditUpdate_Record
  91. Else
  92. MsgBox "This entry already exist.", vbExclamation, "Duplicate Entry"
  93. txtName.SetFocus
  94. SendKeys "{HOME}+{END}"
  95. Exit Sub
  96. End If
  97. End With
  98. End With
  99. End If
  100. End If
  101. Exit Sub
  102.  
  103. EditUpdate_Record:
  104. With dtaDB
  105. .RecordSource = "SELECT * FROM DirectoryList WHERE ID='" & vID & "'"
  106. .Refresh
  107. With .Recordset
  108. If .BOF = True Then
  109. MsgBox "The record you want to edit/update doesn't exist.", vbExclamation, "Not Found"
  110. Exit Sub
  111. Else
  112. .Edit
  113. !Name = txtName
  114. !TelNum = txtTelNum
  115. !Address = txtAddress
  116. !City = txtCity
  117. .Update
  118. Call Default_Obj
  119. Call Show_Existing("SELECT * FROM DirectoryList")
  120. End If
  121. End With
  122. End With
  123. End If
  124.  
  125. End Sub
  126.  
  127. Private Sub cmdNewSave_Click()
  128.  
  129. If cmdNewSave.Caption = "&New" Then
  130. Call Default_Obj
  131. cmdNewSave.Caption = "&Save"
  132. fraSearch.Enabled = False
  133. fraInfo.Enabled = True
  134. FraBinfo.Enabled = True
  135. cmdNewSave.Caption = "&Save"
  136. cmdCloseCancel.Caption = "&Cancel"
  137. txtName.SetFocus
  138. Else
  139. If Len(txtName) = 0 Then
  140. MsgBox "Full Name Textbox contains no data.", vbExclamation, "Empty Textbox"
  141. txtName.SetFocus
  142. Exit Sub
  143. End If
  144.  
  145. If Len(txtAddress) = 0 Then
  146. MsgBox "Home Address Textbox contains no data.", vbExclamation, "Empty Textbox"
  147. txtAddress.SetFocus
  148. Exit Sub
  149. End If
  150.  
  151. If Len(txtTelNum) = 0 Then
  152. MsgBox "Telephone # Textbox contains no data.", vbExclamation, "Empty Textbox"
  153. txtTelNum.SetFocus
  154. Exit Sub
  155. End If
  156.  
  157. If Len(txtCity) = 0 Then
  158. MsgBox "City Textbox contains no data.", vbExclamation, "Empty Textbox"
  159. txtCity.SetFocus
  160. Exit Sub
  161. End If
  162.  
  163. With dtaDB
  164. .RecordSource = "SELECT * FROM DirectoryList WHERE Name='" & txtName & "' AND Address='" & txtAddress & "' AND TelNum ='" & txtTelNum & "' AND City='" & txtCity & "'"
  165. .Refresh
  166. With .Recordset
  167. If .BOF = True Then
  168. .AddNew
  169. !ID = Format(Date, "mmddyy") & Format(Time, "hhmmss")
  170. !Name = txtName
  171. !TelNum = txtTelNum
  172. !Address = txtAddress
  173. !City = txtCity
  174. .Update
  175. Call Show_Existing("SELECT * FROM DirectoryList")
  176. MsgBox "New entry was successfully addedd.", vbInformation, "Record Saved"
  177. Call Default_Obj
  178. Exit Sub
  179. Else
  180. MsgBox "This entry already exist.", vbExclamation, "Duplicate Entry"
  181. txtName.SetFocus
  182. SendKeys "{HOME}+{END}"
  183. Exit Sub
  184. End If
  185. End With
  186. End With
  187. End If
  188.  
  189. End Sub
  190.  
  191. Private Sub Form_Load()
  192.  
  193. dtaDB.DatabaseName = App.Path & "\TelDir.mdb"
  194. Call Default_Obj
  195. Call Show_Existing("SELECT * FROM DirectoryList")
  196.  
  197. End Sub
  198.  
  199. Private Sub Default_Obj()
  200.  
  201. With Me
  202. .txtName = ""
  203. .txtAddress = ""
  204. .txtSearchKey = ""
  205. .txtTelNum = ""
  206. .txtCity = ""
  207. .cboSearchBy.Text = .cboSearchBy.List(0)
  208. .cmdCloseCancel.Caption = "&Close"
  209. .cmdDelete.Enabled = False
  210. .cmdEditUpdate.Caption = "&Edit"
  211. .cmdEditUpdate.Enabled = False
  212. .cmdNewSave.Caption = "&New"
  213. .fraInfo.Enabled = False
  214. .FraBinfo.Enabled = False
  215. .fraSearch.Enabled = True
  216.  
  217. End With
  218.  
  219. End Sub
  220.  
  221.  
  222. Private Sub Show_Existing(vSQL As String)
  223.  
  224. Dim vLst As ListItem
  225. Dim SubItems As String
  226. lstExisting.ListItems.Clear
  227. With dtaDB
  228. .RecordSource = vSQL
  229. .Refresh
  230. With .Recordset
  231. If .BOF = True Then Exit Sub
  232. .MoveFirst
  233. While Not .EOF
  234. Set vLst = lstExisting.ListItems.Add(, , !ID)
  235. vLst.SubItems(1) = !Name
  236. vLst.SubItems(2) = !Address
  237. vLst.SubItems(3) = !TelNum
  238. vLst.SubItems(4) = !City
  239. .MoveNext
  240. Wend
  241. End With
  242. End With
  243.  
  244. lblCnt = "# of Records : " & lstExisting.ListItems.Count
  245. lstExisting.Refresh
  246. lstExisting.Refresh
  247.  
  248. End Sub
  249.  
  250. Private Sub lstExisting_Click()
  251.  
  252. Dim vI As Integer
  253.  
  254. If lstExisting.ListItems.Count = 0 Then Exit Sub
  255.  
  256. Call Default_Obj
  257.  
  258. cmdEditUpdate.Enabled = True
  259. cmdDelete.Enabled = True
  260.  
  261. vI = lstExisting.SelectedItem.Index
  262. vID = lstExisting.SelectedItem
  263.  
  264. txtName = lstExisting.ListItems(vI).ListSubItems(1)
  265. txtAddress = lstExisting.ListItems(vI).ListSubItems(2)
  266. txtTelNum = lstExisting.ListItems(vI).ListSubItems(3)
  267. txtCity = lstExisting.ListItems(vI).ListSubItems(4)
  268. End Sub
  269.  
  270. Private Sub txtSearchKey_Change()
  271.  
  272. Dim vSQL As String
  273.  
  274. Select Case cboSearchBy.Text
  275. Case "Name"
  276. vSQL = "SELECT * FROM DirectoryList WHERE Name LIKE '" & txtSearchKey & "*'"
  277. Case "Address"
  278. vSQL = "SELECT * FROM DirectoryList WHERE Address LIKE '" & txtSearchKey & "*'"
  279. Case "Telephone #"
  280. vSQL = "SELECT * FROM DirectoryList WHERE TelNum LIKE '*" & txtSearchKey & "'"
  281. Case "City"
  282. vSQL = "SELECT * FROM DirectoryList WHERE City LIKE '" & txtSearchKey & "*'"
  283. End Select
  284.  
  285. Call Show_Existing(vSQL)
  286.  
  287. End Sub
Last edited by cscgal; Sep 27th, 2008 at 8:04 pm. Reason: Added code tags
Reply With Quote Quick reply to this message  
Join Date: Feb 2008
Posts: 509
Reputation: selvaganapathy is an unknown quantity at this point 
Solved Threads: 88
selvaganapathy's Avatar
selvaganapathy selvaganapathy is offline Offline
Posting Pro

Re: ERROR in VB

 
0
  #4
Sep 27th, 2008
Hi, The Problem is on your Access Database version.

If you using the data base that is higher version, data control wont access it.

Use ADODB for accessing the Different versions.

Or

Change the Data base to the earlier version.
KSG
Reply With Quote Quick reply to this message  
Join Date: May 2008
Posts: 41
Reputation: dspnhn is an unknown quantity at this point 
Solved Threads: 4
dspnhn dspnhn is offline Offline
Light Poster

Re: ERROR in VB

 
0
  #5
Sep 29th, 2008
If you are using Access 2003 or below please add references for ADO 2.1 library if u r using ADO or DAO 3.51 if using otherways.............
Reply With Quote Quick reply to this message  
Join Date: Jul 2007
Posts: 292
Reputation: jireh is an unknown quantity at this point 
Solved Threads: 37
jireh's Avatar
jireh jireh is offline Offline
Posting Whiz in Training

Re: ERROR in VB

 
0
  #6
Sep 29th, 2008
Just choose the highest reference.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the Visual Basic 4 / 5 / 6 Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC