473,473 Members | 1,745 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

ADODB and Data control difficulties

Hi all,
I have this project to use the ADODB control to acces and manipulate the
Access DB. I amd the mistake of first doing this project with just the data
control. It worked fine with this control. I adjusted a few things and can
get the ADODB controlto move through the records of the DB, but my menu
controls do not work. I used them to look up certain records through
various criteria. When I click on the lookup, it brings up the box to enter
a letter to find the record but does not find the record and the ADODB
button becomes inactive. I left the button name as dtaAddress, but it is
really an adoAddress. Another funny thing is when I tried to chand the name
of dtaAddress to adoAdress the ADODB control would become inactive then. I
am now trying to get the menu control to work with ADODB I think it has to
do with th refresh method you see in my code, but when I try to change it to
requery, I get an error message. Any help would be greatly appreciated.

Regards,
Kelsey

Option Explicit

Private conn As ADODB.Connection
Private rs As ADODB.Recordset

Private Sub Command1_Click()

End Sub

Private Sub cmdSave_Click()
'when the user clicks the save button, call
'File|Save. (To jump to this procedure, select 'mnufilesave_click' and
press Shift+F2.)
mnuFileSave_Click
End Sub
Private Sub dtaAddress_Reposition()

Dim X As Integer, NewRec As Integer

If dtaAddress.EditMode = 2 Then ' You're editing a new record.

mnuFileSave.Enabled = True
'disable add, delete menu items
For X = 0 To 1: mnuRecSub(X).Enabled = False: Next X

Else
mnuFileSave.Enabled = False

For X = 0 To 1: mnuRecSub(X).Enabled = True: Next X

End If
cmdSave.Enabled = mnuFileSave.Enabled
If dtaAddress.Recordset.BOF Then
Beep
mnuRecSub(4).Enabled = False

ElseIf dtaAddress.Recordset.EOF Then
Beep
mnuRecSub(5).Enabled = False

Else
For X = 3 To 6: mnuRecSub(X).Enabled = True: Next X
End If

End Sub
Private Sub Form_Load()

Center Me
lblAddrId.BackColor = txtAddress(1).BackColor
End Sub
Private Sub Form_Unload(Cancel As Integer)
End
End Sub
Private Sub mnuFileExit_Click()
End
End Sub

Private Sub mnuFileSave_Click()
dtaAddress.UpdateRecord

End Sub

Private Sub mnuLookSub_Click(Index As Integer)
Dim Prompt As String, Title As String, Default As String, l As Integer
Dim Sought As String, Field As String, SQL As String

Dim MyCriteria As String

Select Case Index
Case Is < 5

Prompt = Mid$(mnuLookSub(Index).Caption, 4) 'strip out leading "by "
l = InStr(Prompt, "&")
If l <> 0 Then Prompt = Left$(Prompt, l - 1) & Mid$(Prompt, l + 1)

Title = "Search by " & Prompt
Prompt = "Enter all or part of the " & Prompt & " to search for:"
Default = ""
Sought = InputBox(Prompt, Title, Default)
If Sought = "" Then Exit Sub
Select Case Index
Case 0: Field = "Lastname"
Case 1: Field = "Firstname"
Case 2: Field = "Company"
Case 3: Field = "City"
Case 4: Field = "State"

End Select
SQL = "Select * from Addresses where " & Field & " LIKE '" & Sought
& "*'"
Debug.Print SQL

dtaAddress.RecordSource = SQL
dtaAddress.Refresh'<----------here
Case 5

End Select

End Sub

Private Sub mnuRecSub_Click(Index As Integer)

Select Case Index
Case 0 'add
dtaAddress.Recordset.AddNew
txtAddress(1).SetFocus
Case 1 ' delete
If MsgBox("Delete this Record?", vbQuestion + vbYesNo) = vbYes
Then dtaAddress.Recordset.Delete
dtaAddress.Recordset.MovePrevious

Case 3 ' first
dtaAddress.Recordset.MoveFirst

Case 4 ' previous
dtaAddress.Recordset.MovePrevious
If dtaAddress.Recordset.BOF Then
Beep
dtaAddress.Recordset.MoveFirst
End If

Case 5 ' next
dtaAddress.Recordset.MoveNext
If dtaAddress.Recordset.EOF Then
Beep
dtaAddress.Recordset.MoveLast
End If
Case 6 ' last
dtaAddress.Recordset.MoveLast
End Select

End Sub
Private Sub txtAddress_Change(Index As Integer)
mnuFileSave.Enabled = True
cmdSave.Enabled = True
End Sub

Private Sub txtAddress_GotFocus(Index As Integer)

Sel txtAddress(Index)
End Sub
Private Sub txtAddress_LostFocus(Index As Integer)
Dim Temp As String
If Index = 10 Or Index = 11 Or Index = 13 Then
If txtAddress(8) = "USA" And txtAddress(Index).Text Like
"##########" Then
Temp = "(" & Left$(txtAddress(Index), 3) & ") "
Temp = Temp & Mid$(txtAddress(Index), 4, 3) & "-"
Temp = Temp & Mid$(txtAddress(Index), 7)
txtAddress(Index) = Temp
End If
End If


End Sub
'Then the added module
Option Explicit
Public Sub Center(f As Form)
f.Move (Screen.Width - f.Width) / 2, (Screen.Height - f.Height) / 2
End Sub
Public Sub Sel(c As Control)
If TypeOf c Is TextBox Then
c.SelStart = 0
c.SelLength = Len(c)
End If
End Sub
Sub Stat(Msg As String)
If frmMain.lblStatus <> Msg Then frmMain.lblStatus = Msg
End Sub
Jul 17 '05 #1
0 3051

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

21
by: Batista, Facundo | last post by:
Here I send it. Suggestions and all kinds of recomendations are more than welcomed. If it all goes ok, it'll be a PEP when I finish writing/modifying the code. Thank you. .. Facundo
4
by: KLomax | last post by:
I have a VB6 com object that uses ADO 2.1 for data access. I have referenced this object in a aspx application. It works fine on my local development machine. On our staging server, it errors when...
0
by: elcc1958 | last post by:
I need to support a VB6 application that will be receiving disconnected ADODB.Recordset from out DotNet solution. Our dotnet solution deals with System.Data.DataTable. I need to populate a...
0
by: Channing Jones | last post by:
Hello everyone, I am trying to store data in a binary field of an SQL-Server table using ADODB. So far, I have managed to store a record but not any data in the binary field. I only get...
0
by: Ireneus Broncel | last post by:
I have a class which reads Groups and Users from ActiveDirectory. The Problem is, that i have about 10000 rows as product. When I am trying to read the "memberOf" Objects out of this field i get...
3
by: | last post by:
Hello ppl, I have snippet that works fine udner ADODB with VB6, but something wrong with it in Vb.NET. Anyone can help? Recordset1 (ADODB.Recordset) Error: Arguments are of the wrong type, are...
4
by: Ames111 | last post by:
Hi I have an application that connects to a SQl database on my computer via an ADODB connection: ADODB.Connection Conn = new ADODB.Connection(); Conn.ConnectionString = ("Driver={SQL...
1
by: Slim | last post by:
What are the pros and cons of using ADODB in ASP.NET v System.Data namespace? I not refereeing to supplying data to controls but for manipulating with code. I prefer to use ADODB, but is ...
2
EYE4U
by: EYE4U | last post by:
Hi all, This is how you can connect to an Access Database using ADODB.. First add a reference to Microsoft ActiveX Data Objects 2.0 Library Now to lets Declare some variables : Private Con...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.