Specified cast is invalid...


You get this error when compiling your application:

Specified cast is invalid...

Generally, this occurs in an existing application that previously compiled correctly but was recently modified via the Query Wizard.  If you added another query clause that caused two or more tables to be joined, then a “custom query” is created and previously working code customizations referring to one of the referenced tables no longer work.


Previously working code customizations with references such as these are no longer valid:

Dim MyRec As CustomersRecord

MyRec = CType(Me.GetRecord(False), CustomersRecord)

Instead of referring to “CustomersRecord”, modify your code customizations to refer to the custom query created when you joined the tables in the Query Wizard.

See Also

Part VII:  Troubleshooting Applications

Application Generation and Compilation Error Messages