using vba change data
The UK's Number 1 for Microsoft Office Training Add this page to your favourites/bookmarksBookmark page
 
View printable version of pagePrintable version
Plus One Google
Customer: Sign in
Delegate: Sign in
Trainer: Log in

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

resolvedResolved · Medium Priority · Version 2003

replyReply Thu 7 May 2009, 16:05Delegate Charlotte said...

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

replyReply Mon 11 May 2009, 09:43Trainer Stephen said...

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.

 

Please browse our web site to find out more about
access courses in london and other Microsoft training courses.

Access tip:

Deleting duplicate records from a table

You cannot delete records tables where there duplicate records. A way around this is to create a new table which wont hold the duplicates. and then deleting the old table.

1. Use a make-table query based on this table only. IMPORTANT - Ensure that you include all of the fields from your original table or you may loose data.

2. Open the query's property sheet by using VIEW, QUERY, PROPERTIES, and set the Unique Values property to Yes

3. Because you have selected the Unique Values to Yes when you run the query, Access creates a new table without duplicate records. You can now delete the old table and rename the new one.

View all Access hints and tips


Microsoft Certified Partner Accredited Training Provider: Institute of IT Training Institute of Leadership and Management - Certified Courses Security Seal verified by visa, mastercard securecard