dbTalk Databases Forums  

Can this be done in Access

comp.databases.ms-access comp.databases.ms-access


Discuss Can this be done in Access in the comp.databases.ms-access forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Bob
 
Posts: n/a

Default Can this be done in Access - 07-29-2003 , 01:03 PM






Hello

I have an excel spreadsheet that that will be named different each
time. What I need to do is be able to open the file in free file and
have the data populate text boxes on 3 forms. I may be able to squeeze
al the boxes on to 1 or 2 forms if need be (Hopefully) I need to
populate the textboxes so I can update the database after I verify
that all the fields have the correct info in them. Can this be done?

Thanks Bob

Dim ExApp As Object
Dim WkBk As Object
Dim WkSht As Object
Dim tmpSheet As Object
'Set myexcel = CreateObject("Excel.Application")

Set ExApp = CreateObject("Excel.Application") 'Creates new instance
of Excel
strFile = ExApp.GetOpenFilename 'Opens dialog box so user can
pick file to open
Set WkBk = ExApp.Workbooks
WkBk.Open strFile 'Opens chosen file
Set WkSht = ExApp.ActiveSheet 'Selects the active (topmost)
worksheet

'On Form1
txtAdd.Text = WkSht.Cells(7, 3) 'Puts the cell value into the
text box
txtAdd2.Text = WkSht.Cells(8, 3)
txtAdd3.Text = WkSht.Cells(9, 3)
txtCity.Text = WkSht.Cells(10, 3)
txtContact.Text = WkSht.Cells(11, 3)
txtCustomer.Text = WkSht.Cells(6, 3)
txtDate.Text = WkSht.Cells(2, 5)
txtPhone.Text = WkSht.Cells(11, 8)
txtShipper.Text = WkSht.Cells(5, 3)
txtState.Text = WkSht.Cells(10, 6)
txtTech.Text = WkSht.Cells(2, 8)
txtZip.Text = WkSht.Cells(10, 8)

'On Form2
txtCams.Text = WkSht.Cells(17, 3)
txtCPU.Text = WkSht.Cells(19, 3)
txtIP.Text = WkSht.Cells(18, 3)
txtLic.Text = WkSht.Cells(18, 8)
txtMail.Text = WkSht.Cells(17, 8)
txtModem.Text = WkSht.Cells(16, 8)
txtOS.Text = WkSht.Cells(16, 3)
txtSoftWare.Text = WkSht.Cells(15, 3)
txtVer.Text = WkSht.Cells(15, 7)

'On Form3
txtAddPtr.Text = WkSht.Cells(29, 4)
txtAddPtr1.Text = WkSht.Cells(29, 6)
txtAddPtr2.Text = WkSht.Cells(29, 8)
txtKey.Text = WkSht.Cells(26, 4)
txtKey1.Text = WkSht.Cells(26, 6)
txtKey2.Text = WkSht.Cells(26, 8)
txtMon.Text = WkSht.Cells(25, 4)
txtMon1.Text = WkSht.Cells(25, 6)
txtMon2.Text = WkSht.Cells(25, 8)
txtMse.Text = WkSht.Cells(27, 4)
txtMse1.Text = WkSht.Cells(27, 6)
txtMse2.Text = WkSht.Cells(27, 8)
txtOther.Text = WkSht.Cells(31, 4)
txtOther1.Text = WkSht.Cells(31, 6)
txtOther2.Text = WkSht.Cells(31, 8)
txtRpt.Text = WkSht.Cells(28, 4)
txtRpt1.Text = WkSht.Cells(28, 6)
txtRpt2.Text = WkSht.Cells(28, 8)
txtScale.Text = WkSht.Cells(30, 4)
txtScale1.Text = WkSht.Cells(30, 6)
txtScale2.Text = WkSht.Cells(30, 8)
txtSysUnit.Text = WkSht.Cells(24, 4)
txtSysUnit1.Text = WkSht.Cells(24, 6)
txtSysUnit2.Text = WkSht.Cells(24, 8)

ExApp.Workbooks.Close
Set ExApp = Nothing
Set WkBk = Nothing
Set WkSht = Nothing

Reply With Quote
  #2  
Old   
Bob
 
Posts: n/a

Default Re: Can this be done in Access - 07-29-2003 , 05:16 PM








I think that is my problem. The spreadsheet will alway have a
different name. I am trying to learn how to do more in Access than in
Visual when dealing with databases
Quote:
Try this out. Go to Tables. Click File/Import/GetExternalData. Now
select a spreadsheet. Click on open. OK, you get the gist of the
situation.

If you know the Excel filename, you can
Docmd.DeleteObject acTable,"LinkedSpreadsheet"
Docmd.TransferSpreadsheet acLink, ....
DOcmd.OpenForm "YourFormWithTextBoxesName"...

If this is multiuser, you may have a prob, but you'd have one anyway
wnat you are suggesting.


Reply With Quote
  #3  
Old   
Patrick Finucane
 
Posts: n/a

Default Re: Can this be done in Access - 07-29-2003 , 10:53 PM



Bob wrote:
Quote:
I think that is my problem. The spreadsheet will alway have a
different name. I am trying to learn how to do more in Access than in
Visual when dealing with databases

Try this out. Go to Tables. Click File/Import/GetExternalData. Now
select a spreadsheet. Click on open. OK, you get the gist of the
situation.

If you know the Excel filename, you can
Docmd.DeleteObject acTable,"LinkedSpreadsheet"
Docmd.TransferSpreadsheet acLink, ....
DOcmd.OpenForm "YourFormWithTextBoxesName"...

If this is multiuser, you may have a prob, but you'd have one anyway
wnat you are suggesting.
OK. Why not link the spreadsheets to the database. You can have 32K
objects so having a couple hundred won't make a hill of beans in the
grand scheme of things....as long as those 32K don't exceed 1 gig....in
A97.

In your OnOpen event of the form, present another form that displays a
list of all spreadsheets linked to the database. Provide an option to
add a spreadsheet to the list. If the person selects a spreadsheet,
that becomes the recordsource of the form. If the person cancels out,
then in the OnOpen event set Cancel to true.

If you are looking for a magic wand to solve your problem, good luck.
If you have an idea of how you want it to work, spell it out. In your
case, you;re going to have to think out of the box.


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.