read in data from access

M

macroapa

Hi, I have an access data base call xyz.mdb which has 1 table called
AutoPostCount

the table consists of 2 field, the first 'DateDone' and the second
called 'CountDone'.

what I want to be able to do is look up the countdone for the
specified date and then increment that figure by 1.

I know how to add a new record to a data base, but not how to read in
a specific bit of data from a record and how to amend that record.

Any help or pointers appreciated.

Thanks.
 
M

macroapa

Thanks for that, that certainly helps, but i'm having problems
connecting to the database.

I have added the 2 reference mentioned under tools-references and my
code is:

Dim myDatabase As Database
Dim myActiveRecord As Recordset

Set myDatabase = OpenDatabase("J:\PrintCount.mdb")

but is debugs on the Set line of code saying '429' ActiveX component
cant create object.

Any idea's where i;m going wrong? WinXP Professional with OfficeXP

Thanks for the help.
 
C

cyberdude

Hi,

Did you establish the reference from the VB editor? One line in the
webpage that Doug referred to says:

One final tip: In order for this code to run, you must establish a
reference, in your template, to Microsoft DAO 3.51 Object Library and
Microsoft Datasource Interfaces. To do this, open the VB editor and
choose References on the Tools menu.

Hope this helps.

Mike
 
D

Doug Robbins - Word MVP

Have you tried re-booting

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP
 
A

alborg

(sorry if the post is repeated twice- I got an error on the last post)

Hi macroapa:

You might have run into the linking issue that took me quite a long time to
figure out. I have a program that links up to a table located in an external
mdb container. The code that Doug posted is correct, but what you have to do
is to link TWICE to the mdb, once when you open the template and then when
you open the new doc file. So go to your VB editor pane and:

1) Go to YourProjectName-> Microsoft Word Objects-> ThisDocument and place
the following code-

Option Explicit

Private Sub Document_New()
On Error Resume Next
Dim accessword As AccessObject
'Word.Application
Dim Accesswasnotrunning As Boolean ' Flag for final release.
Dim wdWindowStateMaximize As Long
wdWindowStateMaximize = 0
On Error Resume Next
conDBpath2 = "J:\PrintCount.mdb"
Set accessword = GetObject("J:\PrintCount.mdb", "Access.Application")
accessword.Application.Visible = True
If Err.Number <> 0 Then 'test to see if an error occurred
Set accessword = CreateObject("Access.Application")
End If
If Accesswasnotrunning = True Then
accessword.Application.Quit
End If
With accessword
.WindowState = wdWindowStateMinimize
End With
Set accessword = Nothing
On Error GoTo ErrorHandler
Load frmSplashscreen
frmSplashscreen.Show
ErrorHandlerEXit:
Exit Sub
ErrorHandler:
MsgBox "Error No: " & Err.Number & "; Description: " & Err.Description
Resume ErrorHandlerEXit
End Sub

2) In your first popup form, place the following code-

Private Sub UserForm_Initialize()
On Error Resume Next
Application.DisplayAlerts = wdAlertsNone
Dim accessword As Object
Dim Accesswasnotrunning As Boolean ' Flag for final release.
Dim wdWindowStateMaximize As Long
wdWindowStateMaximize = 0
Set accessword = GetObject(, "Access.Application")
If Err.Number <> 0 Then 'test to see if an error occurred
Set accessword = CreateObject("Access.Application")
End If
Set accessword = GetObject("J:\PrintCount.mdb", "Access.Application")
If Err.Number <> 0 Then Accesswasnotrunning = True
Set accessword = CreateObject("J:\PrintCount.mdb",
"Access.Application")
If Accesswasnotrunning = True Then
accessword.Application.Quit
End If
accessword.Application.Visible = False
If Err.Number <> 0 Then 'test to see if an error occurred
Set accessword = CreateObject("Access.Application")
End If
With accessword
End With
Set accessword = Nothing
Proc_Exit:
Exit Sub
Proc_Error:
Call EMRError("WORD EMR Project.dot/" & Me.Name & ":
CommandButton11_Click()", Err.Number, Err.Source, Err.Description)
Resume Proc_Exit
End Sub

So, if you login twice, it'll work.

Regards,
Al
 

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