Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

RE: Why does "#Num!" show up when viewing a linked table?

49 views
Skip to first unread message

Ofer

unread,
Jul 19, 2005, 6:45:05 AM7/19/05
to
Open the table in the original mdb where the table located, if you get the
same thing the run repair and compact on the mdb.
If it doesnt give you the "#Num then re link the table

"Stubanz" wrote:

> When I open a linked table in Access, "#Num!" shows in some of the data
> cells, but not in others in the same columns. I tried changing all the cells'
> formatting to general, then to number, then to text, but none of these
> worked. Any suggestions?
>
> Thanks.

ma...@ezydvd.com.au

unread,
Jul 19, 2005, 8:03:56 PM7/19/05
to
If you're linking to a non-Access table (Excel spreadsheet, text file,
etc), the problem is that the column contains both numbers and
non-numbers. When you link in Access, it analyses the first few values
in each column and determines the data type from them. In your case,
the first few values are numbers, so Access sets the data type to
"Number". Later, when it reads the non-numbers, it displays "#Num!"

If your column SEEMS to contain all numbers, it may be that some of
them have been entered as text, and are causing the error. There are
many reasons that this may happen, which I won't go into here.

Formatting the column to Text AFTER the data has been entered makes no
difference - it'd only work if the formatting was set before the data
entry.

You will need to create the following macro in Excel, which will force
numbers to be treated as text values:

Public Sub SetNumbersToText()
Dim rng As Range

For Each rng In Intersect(ActiveSheet.UsedRange, Selection).Cells
With rng
.NumberFormat = "@"
.Value = " " & .Value
.Value = Mid(.Value, 2)
End With
Next
End Sub

Select the column that is giving you trouble, then run this macro. All
cells will be formatted as Text, and all numbers will be re-entered as
text values. Re-open your database, and the linked table should behave
itself. The troublesome column should now be set to "Text" data type.

Alternatively, if your column is supposed to contain numbers, and some
of them have already been entered as text, try this macro:

Public Sub SetTextToNumbers()
Dim rng As Range

For Each rng In Intersect(ActiveSheet.UsedRange, Selection).Cells
With rng
.NumberFormat = "General"

If IsNumeric(.Value) Then
.Value = Val(.Value)
End If
End With
Next
End Sub

The "#NUM!" values should disappear.

If you're linking to something like a text file, open it as an Excel
spreadsheet, and run the above macro(s).

I hope this helps.

Mark.

0 new messages