Re: How do I declare a variable as a Variant

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: John Vinson (jvinson_at_STOP_SPAM.WysardOfInfo.com)
Date: 05/31/04


Date: Mon, 31 May 2004 14:39:39 -0600

On Mon, 31 May 2004 12:16:03 -0700, "Sandy C"
<anonymous@discussions.microsoft.com> wrote:

>I am running an append query and get this error:
>
>You tried to assign a Null value to a variable that is not a Variant data type. Use the Dim statement to declare the variable as a Variant, and then try the operation again.
>
>How do I do this in the Design View or the SQL window of the query?

Neither; you need to do it in the VBA code which is generating the
error! VBA is one language (which has DIM statements and Variants);
SQL is a different language altogether. I suspect that you're either
calling some VBA function from your query, or that this error is
arising for some other reason.

Please post the SQL view of the query and the VBA of the code that
(I'm guessing) that you're using to launch the query.

                  John W. Vinson[MVP]
    Come for live chats every Tuesday and Thursday
http://go.compuserve.com/msdevapps?loc=us&access=public



Relevant Pages

  • RE: Calculation in a subform
    ... Public Function CalcWeeks(D_Start As Variant, ... You could thus use it to create a calculated column in the query that is ... I tried to use my query as my record source for the subform ... individual may spend 52 weeks in the Sales Department, ...
    (microsoft.public.access.forms)
  • Re: Trap Combo-Box error
    ... bound to a field in the query that is the form's recordsource. ... > The combo box is bound to the form's record source and there is not any ... >>> variable that is not a Variant data Type". ... >>> You tried to assign a Null value to a variable that is not a Variant ...
    (microsoft.public.access.formscoding)
  • Re: Passing null values to a Function
    ... then I use a union query to base the report on. ... Public Function UnitStatus(strUnit As String, strLTResult As Variant, ... UnitStatus = "Test Pending" ...
    (microsoft.public.access.modulesdaovba)
  • Re: Calling a Function in a Query and Form
    ... adding on to what Tom wrote... ... You can use the Nz function to return zero, a zero-length string, or another specified value when a Variant is Null. ... Optional (unless used in a query). ... The DateDiff function can be used to specify what time increment you want returned when you subtract dates ...
    (microsoft.public.access.modulesdaovba)
  • RE: Unable to retrieve Public variable in other modules ...
    ... function in a query, you have to pass it an argument. ... Here is a simple static function that you can assign a value to and it will ... Static Function GetSSN(Optional ByVal varNewSSN As Variant) As String ...
    (microsoft.public.access.formscoding)