Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VB6 Exe works on Developers machine but not client 1

Status
Not open for further replies.

ynnepztem

Programmer
Aug 2, 2001
54
US
I have a VB6 program using an ACCESS database. I have created an EXE and a SETUP package that includes all .OCX files, database, images and EXE. I installed the program on the clients machine but only part of it works. I opened the code on my home machine and the .EDIT action is not present.

My References are:
Visual Basic For Applications
Visual Basic runtime objects and procedures
Visual Basic objects and procedures
OLE Automation
Microsoft DAO 3.6 Object Library
Microsoft Data Formatting Object Library 6.0(SP4)
Microsoft ActiveX Data Objects 2.5 Library
Microsoft Data Binding Collection VB 6.0 (SP4)
Microsoft Access 11.0 Object Library
Microsoft ADO Ext.2.8 for DLL and Security

My Components are:
Microsoft ADO Data Control 6.0 (SP4) (OLEDB)
Microsoft Calendar Control 11.0
Microsoft Data Bound List Controls 6.0
Microsoft DataGrid Control 6.0 (SP5) (OLEDB)

In a module, I put the connection to the database.

Function MakeConnection()
Set db = OpenDatabase("C:\Program Files\Pick of the Litter\PickOfTheLitter.mdb")
End Function

I can't get past the Form_Load event. The error happens at the .EDIT line. When I use intelesense .EDIT is not available, only .EDITMode is. I don't understand this since I have VB6 on both machines (work and home) they are both running Windows XP and use Microsoft Office 2003.

Private Sub Form_Load()
Today = Format(Now, "Short Date")
MakeConnection
Dim diff As Integer
'//Update the pets ages
Set rs = db.OpenRecordset("select * from pets")
With rs
Do While Not rs.EOF
diff = DateDiff("d", !AgeDate, Today)
If DateDiff("d", Today, !AgeDate) >= 365 Then
.Edit
!Age = !Age + 1
!AgeDate = Today
.Update
.MoveNext
Else
.MoveNext
End If
Loop
End With
rs.Close
db.Close
FillColorCombo
FillType
End Sub

 
The problem is that

a) you have references to both DAO and ADO, both of which have a recordset object (that differ from each other)

b) you don't appear in the code you have given to have declared rs (or, if you have declared it as a public variable elsewhere, you have merely declared it as a Recordset). This means that VB will try and use the first recordset object of the class library that appears first in the registry - you get the error when it is ADO that appears first.

Solution
Explicitly declare rs something like:

dim rs as DAO.Recordset

(it is DAO that supports .Edit)

 
Thanks. I made the suggested alteration and I got past the .EDIT problem. Now, on the clients machine, the datagrid does not fill. In the following code, I look for a first and/or last name entered in text boxes on the form. I click the Search button and fire the cmdSearch_Click code. If more than one match is found, the grid should fill with the entries. On my machine at work it performs perfectly, on the clients machine and my machine at home (even in development with VB6) the grids don't fill.

CODE:
*********************************************
Sub FillGrid(ByVal Query As String)
With Adodc1
.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Program Files\Pick of the Litter\PickOfTheLitter.mdb;Persist Security Info=False"
.RecordSource = Query
.Refresh
End With
End Sub
*********************************************

Private Sub cmdSearch_Click()
i = 0
MakeConnection
'//Look for both First and Last name
If txtFirstName.Text <> "" And txtLastName.Text <> "" Then
Set rs = db.OpenRecordset("select * from ClientInfo where LastName = " & "'" & txtLastName & "'" & " and Firstname = " & "'" & FirstName & "'")
'//Count how many found
With rs
'//None found
If rs.EOF Then
MsgBox ("No Record Found")
rs.Close
db.Close
Exit Sub
Else
'//At least one found
rs.MoveFirst
Do Until rs.EOF
If UCase(!LastName) = LastName And UCase(!FirstName) = FirstName Then
i = i + 1
rs.MoveNext
End If
Loop
End If
End With
'//If there are more than one client with the same first and last name, show in a grid
If i > 1 Then
FillGrid ("Select * from ClientInfo where LastName = " & _
"'" & LastName & "'" & " and Firstname = " & "'" & FirstName & "'")
DataGrid2.Visible = True
rs.Close
db.Close
Exit Sub
Else
'//Only one client found
FillClientInfo ("select * from ClientInfo where LastName = " & "'" & LastName & "'" & " and Firstname = " & "'" & FirstName & "'")
txtFirstName.Text = ""
txtLastName.Text = ""
frmFind.Visible = False
End If
Else
'//No match, keep searching
'//Only look for Last name
If txtFirstName.Text = "" And txtLastName.Text <> "" Then
Set rs = db.OpenRecordset("select * from ClientInfo where LastName = " & "'" & LastName & "'")
'//Count how many found
With rs
'//None found
If rs.EOF Then
MsgBox ("No Record Found")
rs.Close
db.Close
Exit Sub
Else
'//At least one found
rs.MoveFirst
Do Until rs.EOF
If UCase(!LastName) = LastName Then
i = i + 1
rs.MoveNext
End If
Loop
End If
End With
'//If there are more than one client with the same last name, show in a grid
If i > 1 Then
FillGrid ("Select * from ClientInfo where LastName = " & "'" & LastName & "'")
DataGrid2.Visible = True
rs.Close
db.Close
Exit Sub
Else
'//Only one client found
FillClientInfo ("select * from ClientInfo where LastName = " & "'" & LastName & "'")
frmMain.frameClient.Visible = True
End If
Else
'//No match, keep searching
'//Only look for First name
If txtFirstName.Text <> "" And txtLastName.Text = "" Then
Set rs = db.OpenRecordset("select * from ClientInfo where firstname = " & "'" & FirstName & "'")
'//Count how many found
With rs
'//None found
If rs.EOF Then
MsgBox ("No Record Found")
rs.Close
db.Close
Exit Sub
Else
'//At least one found
rs.MoveFirst
Do Until rs.EOF
If UCase(!FirstName) = FirstName Then
i = i + 1
rs.MoveNext
End If
Loop
End If
End With
'//If there are more than one client with the same first name, show in a grid
If i > 1 Then
FillGrid ("Select * from ClientInfo where FirstName = " & "'" & FirstName & "'")
DataGrid2.Visible = True
rs.Close
db.Close
Exit Sub
Else
'//Only one client found
FillClientInfo ("select * from ClientInfo where FirstName = " & "'" & FirstName & "'")
End If
Else
'//No name was entered
MsgBox ("You must fill in either a first or last name to find a client")
db.Close
Exit Sub
End If
End If
End If
Unload Me
End Sub
**************************************************
DECLARATIONS:

Option Explicit
Public Declare Function SendMessage Lib "user32.dll" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Integer, ByVal lParam As Any) As Long
Global Today As Date
Global SQL As String
Global ID As Integer
Global Mixed As String
Global wrkJet As Workspace
Global db As Database
Global rs As DAO.RecordSet
Global ClientID As Integer
Global ServiceID As String
Global PetID As Integer
Global PetType As String
Global PetColor As String
Global PetBreed As String
Global PetSex As String
Global AreaCode As String
Global Phone1 As String
Global Phone2 As String
Global InTime As Date
Global OutTime As Date
Global i As Integer
Global NewClient As String
Global FindClient As Boolean
Global FirstName As String
Global LastName As String
Global Blade As String
Global Nail As Boolean
Global Bath As Boolean
Global NailEars As Boolean
Global FleaDip As Boolean
Global Cut As Boolean
Global Teeth As Boolean
Global NoPet As String
Global Dup As Boolean 'True - Client already in database
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top