Charlotte has attended:
Access VBA course
Using VBA to change a data type
We receive large data files with field names 'memo' when they should be text or number - is there a way of changing this using VBA - currently we try changing it manually and get a memory error.
RE: Using VBA to change a data type
Hi Charlotte
Thank you for your question
You can convert memo filed data into string and integer values by using cstring and cint vb functions. The following code provides some examples
Set dbData = CurrentDb
Set rstEmployee = dbData.OpenRecordSet("Employees")
rstEmployee.MoveFirst
strAddress = rstEmployee.Fields("Address") 'This is a memo field
MsgBox CInt(strAddress)
MsgBox CInt(strAddress) * 30
MsgBox CStr(strAddress)
Hope this is useful
Regards
Stephen