Forum home » Delegate support and help forum » Microsoft Access VBA Training and help » Using VBA to change a data type
Using VBA to change a data type
Resolved · Medium Priority · Version 2003
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.
For upcoming training course dates see: Pricing & availability
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
Mon 18 May 2009: Automatically marked as resolved.
|
