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 wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

output excel value to access table

Status
Not open for further replies.

MikeCDPQ

Technical User
Sep 11, 2003
173
CA
I am using an Excel user form with a calendar and I need to output the selected date to an access table.

I have everything else, all I am missing is the instruction to replace the 1 value in my access table with the value in the excel spreadsheet.

Can one have an update query in access that uses a variable stored in a script as an UPDATE TO value ???

Any suggestions will be appreciated.

Thanks,

Mike


 
Mike,

Are you using ADO or DAO or what?

Skip,

[red]Be advised:[/red] [glasses]
Alcohol and Calculus do not mix!
If you drink, don't derive! [tongue]
 
Code:
   With rst
      .Edit
      !MyDate = MyExcelValue
      .Update
   End With
where rst is a recordset that you want to update.

Skip,

[red]Be advised:[/red] [glasses]
Alcohol and Calculus do not mix!
If you drink, don't derive! [tongue]
 
Skip,

Im not very familiar with VB Access.

What is RST to be replaced by ?

Here is what I have so far, i know I am m missing the reference to my access table ("DATE") but I don't even know how to refer to it.

Function UpdateDateTable()


Dim SelectedDate As Date
Dim AccessDate As Date
Dim DateTable As TableDef

Set calendardate = GetObject("G:\Department Shared Data\Purchasing\Analysis\Banner Aged Reports\CalendarForm.xls")

AccessDate = calendardate.Sheets("sheet1").Range("A1").Value

With rst
.Edit
!SelectedDate = calendardate
.Update
End With


Application.CloseCurrentDatabase
Application.Quit acExit
Set Application = Nothing


End Function
 
You have to open a recordset (rst)
Code:
  Set db = OpenDatabase(YourAccessDatabase)
  SqlToSelectRecordsToUpdate = "Select...From...Where..."
  Set rst = db.OpenRecordset(SqlToSelectRecordsToUpdate, dbOpenDynamic)

AccessDate = calendardate.Sheets("sheet1").Range("A1").Value

    With rst
      .Edit
      !SelectedDate = AccessDate 
      .Update
    End With

  rst.close
  db.close

  Set rst = nothing
  Set db = Nothing

Skip,

[red]Be advised:[/red] [glasses]
Alcohol and Calculus do not mix!
If you drink, don't derive! [tongue]
 
BTW,

If you don't have DAO HELP, search for
[tt]
DAO360.CHM
[/tt]
on your C drive.

Skip,

[red]Be advised:[/red] [glasses]
Alcohol and Calculus do not mix!
If you drink, don't derive! [tongue]
 
Skip,

Thanks for taking the time to help me.

Unfortunately, not being overly familiar with VB for access, I could not get your script to work. I'm sure that someone with more experience would have caught on right away.

Since my access table will always only have only 1 record (a date) I decided to instead have a linked table to the excel spreadsheet where the date is saved. It works beautifully.

Thanks again for your help, always appreciated.

Sincerely,

Mike
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top