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

Loading Excel into Access

Status
Not open for further replies.

sqlmann

Technical User
May 5, 2009
15
IN
Tried to load excel data into access database using access modules.
Tried the follwing steps to load
Step 1: OPen excel using ADODB provider _working fine without any issue
Step 2 : Store the value into recordset -Like "Select * from [PDF file$](Excl sheet name)

Step 3: Read each record and update it into Acces database

Problem is :

In the Excel sheet, one column has String value and some numeric value like 'P3','p4' and 3 ok ?. This program inserts only string value and if the value is numeric it inserts as null into database.

Pls advise.. how to solve this?
 


Hi,

The NUMBER 3 and the CHARACTER 3 are to totally different values in a computer.

Why would you have TEXT & NUMBERS in the same column in Excel? I know its possible, but do you expect to do arithmetic on these numbers? Your NUMBERS ought to be converted to TEXT in Excel.

Run some code like this to convert...
Code:
Sub Num2Chr()
'select any cell in the column you want to convert
'number to character
  Dim r As Range
  Set r = Selection
  With r.Parent.UsedRange
    For Each r In .Range(.Cells(.Row, r.Column), .Cells(.Row + .Rows.Count - 1, r.Column))
      With r
        If IsNumeric(.Value) Then .Value = "'" & .Value
      End With
    Next
  End With
End Sub


Skip,
[sub]
[glasses]Just traded in my old subtlety...
for a NUANCE![tongue][/sub]
 
Skip, just to know, doesn't the @ FormatNumber suffice ?

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 



PHV,

I doubt that just formatting the cells changes anything.

As a rule, format only changes the DISPLAY of values. Dates, leading and trialing zeros, dashes, in formats really change nothing in the underlying value, which is what the query is accessing.

Skip,
[sub]
[glasses]Just traded in my old subtlety...
for a NUANCE![tongue][/sub]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top