Please help: problem working with Access from VB6 application

S

sasha

My VB 6 application works Access database. I've setup a reference
project to Access Data Object.
I've got two issues that I don't know how to resolve. Can anyone
help? Also, if you can point me to a chapter in help or anywhere where
I can read more on the subject. Search key words I came up with bring
way to many unrelated results. Below are the two issues.
1. At some point I displayed an Access form. When I change data in the
form, they seemed to be successful. However, if I open the same
database from Access, the changes I made from this form were not
applied. If I re-display the from form my application, the form shows
that the data was changed. It looks like if I make edits using form
called from the VB6 application, they'd be kept in a separate copy of
the database. What am I doing wrong?

Here is the code:
Dim AccessApp As Access.Application
Set AccessApp = New Access.Application
' path to the database is the same as specified in properties of my
project's data enviroment
' ex. D:\filename.mdb
AccessApp.OpenCurrentDatabase _
deShopFloor.conShopFloor.Properties("Data
Source").Value
Dim sWhereCondition As String
sWhereCondition = "[BATCH] = " & 4039
AccessApp.DoCmd.OpenForm "BatchEdit", , , sWhereCondition
AccessApp.Visible = True

Set AccessApp = Nothing

2. I was trying to print access report and it works fine with the below
code. I also wanted to change a printer it goes to. However whatever
ways I tried, it always went to a default printer. I've tried
changing printer object, application.printer object, access.printer
object - nothing had any effect.
On Error GoTo ErrorHandler
Dim AccessApp As Access.Application
Set AccessApp = New Access.Application
AccessApp.OpenCurrentDatabase _

deShopFloor.conShopFloor.Properties("Data Source").Value
AccessApp.Visible = True

Dim sWhereCondition As String
sWhereCondition = "[BATCH] = " & 4039
AccessApp.DoCmd.OpenReport "Time Card", acViewNormal, ,
sWhereCondition
AccessApp.DoCmd.OpenReport "Press", acViewPreview, , sWhereCondition

AccessApp.CloseCurrentDatabase
AccessApp.Quit
Set AccessApp = Nothing

Thank you,
Alex
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top