Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Send Data to Access

I have a spreadsheet with one row of information. The first field is a
Julian Date. I need to go to Access and if the Julian Date already exists
in the table called "Production" then update that record with the new info.
But if the Julian date is not in the table, I simply need to add the row as
a new record.

Thanks for any help!!


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 812
Default Send Data to Access

I have a spreadsheet with one row of information. The first field is a
Julian Date. I need to go to Access and if the Julian Date already exists
in the table called "Production" then update that record with the new

info.
But if the Julian date is not in the table, I simply need to add the row

as
a new record.


Something like the following should work.

HTH,
Merjet

Sub Macro1()
'Microsoft DAO x.x must be checked at menu Tools | References
Dim db As DAO.Database
Dim rs As Recordset
Dim bFound As Boolean

Set db = OpenDatabase("C:\Path\db1.mdb")
Set rs = db.OpenRecordset("Production")
bFound = False
Do Until rs.EOF Or bFound = True
rs.MoveNext
If Sheets("Sheet1").Range("A2") = rs("Day") Then
bFound = True
rs.Edit
rs("Sales") = Sheets("Sheet1").Range("B2")
rs.Update
End If
Loop
If bFound = False Then
With rs
.AddNew
!Day = c
!Sales = Sheets("Sheet1").Range("B2")
.Update
End With
End If
rs.close
Set rs = Nothing
db.close
Set db = Nothing
End Sub


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Send Data to Access

Thanks!! It worked perfectly :)

"merjet" wrote in message
news:QFRlb.8811$e01.20360@attbi_s02...
I have a spreadsheet with one row of information. The first field is a
Julian Date. I need to go to Access and if the Julian Date already

exists
in the table called "Production" then update that record with the new

info.
But if the Julian date is not in the table, I simply need to add the row

as
a new record.


Something like the following should work.

HTH,
Merjet

Sub Macro1()
'Microsoft DAO x.x must be checked at menu Tools | References
Dim db As DAO.Database
Dim rs As Recordset
Dim bFound As Boolean

Set db = OpenDatabase("C:\Path\db1.mdb")
Set rs = db.OpenRecordset("Production")
bFound = False
Do Until rs.EOF Or bFound = True
rs.MoveNext
If Sheets("Sheet1").Range("A2") = rs("Day") Then
bFound = True
rs.Edit
rs("Sales") = Sheets("Sheet1").Range("B2")
rs.Update
End If
Loop
If bFound = False Then
With rs
.AddNew
!Day = c
!Sales = Sheets("Sheet1").Range("B2")
.Update
End With
End If
rs.close
Set rs = Nothing
db.close
Set db = Nothing
End Sub




Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Bypass: A program is trying to send mail using Item.Send prompt Vick Excel Discussion (Misc queries) 1 June 25th 09 03:31 AM
Can Excel access data from Access?! Al Excel Discussion (Misc queries) 5 April 5th 08 03:52 PM
Send multi data (Graph/Cell data) to Word doc as 1 item (no cells) Tom-LE Excel Discussion (Misc queries) 0 August 30th 06 10:10 PM
My send to in excel/word does not offer send as attachment Mstink Excel Discussion (Misc queries) 11 March 16th 06 02:49 PM
Send Excel data to Access through button julesferreira Excel Discussion (Misc queries) 1 June 17th 05 07:30 PM


All times are GMT +1. The time now is 06:34 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"