473,325 Members | 2,860 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,325 software developers and data experts.

How can I get this to work Please!

Bob
Hello

I have an excel spreadsheet that will alway be named differently. I
need to import the data into text boxes so I can save it to a
database. All the textboxes will not fit on a single form so I had to
brak it up into 3 forms. I may be able to get it to 2. What I am
trying to get is when I select the file I would like it to populate
the 3 forms and text boxes at the same time. Thn I can next my way
thru each form to verify the data before saving it. I do not know how
to create a module.

If anyone can help me I would be greatful. I am still new to VB

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)
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
Thanks
Bob
Jul 17 '05 #1
1 1879
Try creating a class object first that will read the Excel spreadsheet
and hold all the values you need. Then create a reference to that
object, grab the data from Excel and store the values in their own
properties, and those properties will be accessible from anywhere in
your application (as long as you make the class reference a global
var).

By doing that, you are creating a centralized "box" for all your data.
With that, you can create a couple of functions in that class called
"SaveData" and it will write out to the database. Bascially what I am
trying to say it separate the presentation and data layers since the
data is one layer and the presentation is 3 layers.

I hope this helps!
Alex
Jul 17 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: eric cocozza | last post by:
Hi, I just moved a python program to a new server, and I'm getting path errors. It relys on the pear library and a image processing one. Please respond with cost based on 1/hr of work, and...
2
by: rked | last post by:
I get nameSPAN1 is undefined when I place cursor in comments box.. <%@ LANGUAGE="VBScript" %> <% DIM ipAddress ipAddress=Request.Servervariables("REMOTE_HOST") %> <html> <head> <meta...
6
by: x muzuo | last post by:
Hi guys, I have got a prob of javascript form validation which just doesnt work with my ASP code. Can any one help me out please. Here is the code: ...
10
by: Nathaniel Branden | last post by:
Hello. This isn't really an Access question. I just want to know whether Tony Toews is retarded. In that vain, I have pasted down his last thirty or so posts for someone out there to respond. ...
4
by: ={ Advocated }= | last post by:
Hi there, im in need to use a loop, im not sure exactly how to do it :S ######################## /* * File: Payroll.c * Program to calculate the wage of a user */ #include <stdio.h> int...
6
by: scottyman | last post by:
I can't make this script work properly. I've gone as far as I can with it and the rest is out of my ability. I can do some html editing but I'm lost in the Java world. The script at the bottom of...
1
by: FlashT | last post by:
Hello, I got a script: http://www.mattkruse.com/javascript/autocomplete/index.html It works fine on IE and Opera, but does not on FF. It does something on FF, but not what it should do (check...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.