Acess text field converts in number in excel spreadsheet

G2K

Active Member
Joined
May 29, 2009
Messages
355
Hi Mr Excel,​

i am trying to get data from Ms access to excel Spreadsheet. the table filed in acess is decleared as text and i have stored text,number and decimal(1.5) as well. but when it comes to excel spreadsheet decimal number converts into Date format(30-Dec-1899) automatically.​

below is the code for ur reference---​
sql= "Select * from ABC"

Call dbDisConnect
Dim RecCount As Long
Dim FldCount As Long
Dim RecVal As String
Dim i As Long
Dim j As Long
Call dbConnect
Rst.Open Sql, Con, adOpenKeyset, adLockPessimistic
If Sql = "" Then MsgBox "Invalid Operation", vbInformation, "Caution": Exit Sub
If Rst.RecordCount <= 0 Then MsgBox "No Data", vbInformation, "Display": Exit Sub
RecCount = Rst.RecordCount
FldCount = Rst.Fields.Count - 1
For i = 0 To FldCount
Sheet1.Cells(1, i + 1) = Rst.Fields(i).Name
Next
For i = 1 To RecCount
For j = 0 To FldCount
If Not VBA.IsNull(Rst.Fields(j).Value) Then RecVal = Rst.Fields(j).Value Else RecVal = ""
If VBA.IsDate(RecVal) Then
RecVal = VBA.Format(VBA.CDate(RecVal), "dd-mmm-yyyy")
End If​

Sheet1.Cells(i + 1, j + 1) = RecVal​

Next
Rst.MoveNext
Next
Rst.Close
Call dbDisConnect​


please help.............​
 
Last edited:

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.
I would not use the isdate function. Probably if your field contains a date then Excel will recognize it anyway. Leave the formatting for later.

Alex.
 
Upvote 0
thanks Alex,

i have tried it before, but it's not working.........is there any ohter way.........


thanks.
G2K
 
Upvote 0

Forum statistics

Threads
1,215,053
Messages
6,122,888
Members
449,097
Latest member
dbomb1414

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top