excel and access

I

iris

I have created an excel template with custom properties.

When I close the workbook - I need to update an access table with the custom
properties from excel.

in this code - I can sea the access table (using the msgbox) but - it does
not updates or adding a new recordset to the access table.

Can someone tell me what I'm doing wrong?

Here is the code:

On Error Resume Next

Dim dbDatabase As New ADODB.Connection

Dim rs As New ADODB.Recordset

Dim a As Integer
Dim b As Integer
Dim flag As Boolean
flag = True

If ActiveWorkbook.Path = "" Then
Exit Sub
Else
dbDatabase.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & "Data
Source=C:\masterfood.mdb"
rs.Open "select * from categories order by [mispar];", dbDatabase,
adOpenStatic

With rs!mispar
Do
If ActiveWorkbook.CustomDocumentProperties("מספר מסמך") <> rs!mispar Then
flag = False
MsgBox "no muach" & " " & rs!mispar & " " &
flag
Else: flag = True
End If
rs.MoveNext
Loop Until rs.EOF
End With

If flag = False Then
MsgBox "flag is" & " " & flag
With rs
rs.AddNew
rs!irgun =
ActiveWorkbook.CustomDocumentProperties("irgun")
rs.Update
End With
End If
End If
rs.Close
dbDatabase.Close
Set rs = Nothing
Set dbDatabase = Nothing
Unload UserForm1

Thank you!
 

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