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

error 6 Overflow

Status
Not open for further replies.

GLENEE

Programmer
Feb 9, 2005
64
GB
The following codes takes data from an Access database and dumps into a table and form field of Word. The run time error occurs at the select case statement - case f17, which is trying to put the data into the word table. Any ideas what's wrong?? please.

Dim varX, varForm1900, varDB1900 As Variant
Dim objWord As Object

Set dbTemp = CurrentDb()
varX = DLookup("txtPath", "tblMap", "[autMapID] = 13")
Set objWord = GetObject(varX)
objWord.Application.Visible = False
objWord.Application.DISPLAYALERTS = False
Set rstTempF = dbTemp.OpenRecordset("qry1900", dbOpenDynaset)

For intX = 0 To dbTemp.QueryDefs("qry1900").Fields.Count - 1 'no of fields in record

varDB1900 = "f" & intX + 1
varForm1900 = rstTempF(varDB1900)

Case "f17"
objWord.Tables(17).Columns(1).Cells(1).Range.Text = varForm1900
objWord.FormFields(intX + 1).result = "~"

Case Else

objWord.FormFields(intX + 1).result = varForm1900

End Select

Next

objWord.SAVEAS strFileName
 
I don't know if this is your problem, but the Range.Text property won't be able to handle anything except strings. I suspect non-null values will be OK, but Null values would give you grief.
 
I've tried converting null values to zero length string e.g NZ(rstTempF(varDB1900)), but i still get the overflow error (even when there is a string value the error still occurs). Interestingly the process works fine when run on my work development computer which uses Windows 2000 but on my laptop and other computers that use Windows XP the error occurs.
 
What about this ?
objWord.Tables(17).Columns(1).Cells(1).Range.Text = varForm1900[!] & ""[/!]

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
It doesn't seem to matter what i put in e.g - objWord.Tables(17).Columns(1).Cells(1).Range.Text = "anything" will still result in the overflow error. I think it must be something to do with the operating system. Windows 2000 is fine but XP produces the error. Has anyone else come across this?
 
Anyway, your posted code shouldn't compile properly on any platform as you have a Case without a previous Select ...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top