PC Review


Reply
Thread Tools Rate Thread

Compile Error

 
 
nancy
Guest
Posts: n/a
 
      20th May 2010
I am wanting my program to look at a name in the combo box and determine if
the name is also a participant.

I am receiving a compile error : variant not defined.
when it does this it highlights Particvolu of "particvolu =" Participant"


Dim ParticipantName As Integer

ParticpantName = DCount("ID", "Combobox query", "volID", "Particvolu" = " &
cboName & " And Particvolu = "Participant")

 
Reply With Quote
 
 
 
 
nancy
Guest
Posts: n/a
 
      20th May 2010


"nancy" wrote:

> I am wanting my program to look at a name in the combo box and determine if
> the name is also a participant.
>
> I am receiving a compile error :wrong number of arguments or invalid property assignment.



> Dim ParticipantName As Integer
>
>ParticpantName = DCount("ID", "Combobox query", "volID", "Particvolu", "Relationship" = " & cboName & " And [particvolu] = "Participant")
>

 
Reply With Quote
 
John W. Vinson
Guest
Posts: n/a
 
      20th May 2010
On Thu, 20 May 2010 11:20:05 -0700, nancy <(E-Mail Removed)>
wrote:

>I am wanting my program to look at a name in the combo box and determine if
>the name is also a participant.
>
>I am receiving a compile error : variant not defined.
>when it does this it highlights Particvolu of "particvolu =" Participant"
>
>
>Dim ParticipantName As Integer
>
>ParticpantName = DCount("ID", "Combobox query", "volID", "Particvolu" = " &
>cboName & " And Particvolu = "Participant")


Your quotes are messed up. The third argument to DCount() needs to be a
String, which can be constructed by tacking together string constants
delimited by ", such as "[Particvolu] =", and variable values such as the
names of controls on the form.

This is made more complicated by the fact that a Text criterion must be
delimited by quotemarks, and putting quotemarks inside a string constant
delimited by quotemarks can be confusing (it's possible, just confusing!)

The other thing that's confusing about your example is that you're apparently
asking for records where the field named Particvolu is - at one and the same
time - equal to the value found in the combo box, and ALSO equal to the text
string "Participant". That's probably never going to happen! What is in the
field [Particvolu]? Where is the information that a person is a Participant to
be found in your table? What field contains the participant's name? What is
the value of the combo box: a name (which might not be unique) or a numeric
ParticipantID?
--

John W. Vinson [MVP]
 
Reply With Quote
 
nancy
Guest
Posts: n/a
 
      20th May 2010
Maybe I am going about this the wrong way. ..

The names from the combo box come from a query called “Combobox query”,
where it is joining two tables. The combobox name on the form is “cboName”

The SQL from the Combobox Query is: SELECT table1.volID, volName & " " &
VolLastName AS Expr1, Address1.Inactive, Address1.IDFROM Address1 RIGHT JOIN
table1 ON Address1.ID = table1.ADDRESS1_ID WHERE (((Address1.Inactive)=No))
ORDER BY table1.VolName;

I have also used another query that selects the name if it was a participant
and active:
The SQL for it is “SELECT table1.volID, volName & " " & VolLastName AS
Expr1, Address1.Inactive, Address1.ID, Address1.Particvolu FROM Address1
RIGHT JOIN table1 ON Address1.ID=table1.ADDRESS1_ID WHERE
(((Address1.Inactive)=No) AND ((Address1.Particvolu)="Participant")) ORDER
BY table1.VolName;”

I would like to use the combo box that comes from “Combobox query”, because
I am using it for another macro on the same form.

To answer your question What is in the field [Particvolu] It is a drop
down box that contains either participant or volunteer.

Maybe I could do something like.
If (cboName) <> 0 and [address1.particvolu] = “participant” then…
Suggestions?
 
Reply With Quote
 
John W. Vinson
Guest
Posts: n/a
 
      20th May 2010
On Thu, 20 May 2010 15:11:01 -0700, nancy <(E-Mail Removed)>
wrote:

>Maybe I am going about this the wrong way. ..
>
>The names from the combo box come from a query called Combobox query,
>where it is joining two tables. The combobox name on the form is cboName
>
>The SQL from the Combobox Query is: SELECT table1.volID, volName & " " &
>VolLastName AS Expr1, Address1.Inactive, Address1.IDFROM Address1 RIGHT JOIN
>table1 ON Address1.ID = table1.ADDRESS1_ID WHERE (((Address1.Inactive)=No))
> ORDER BY table1.VolName;
>
>I have also used another query that selects the name if it was a participant
>and active:
>The SQL for it is SELECT table1.volID, volName & " " & VolLastName AS
>Expr1, Address1.Inactive, Address1.ID, Address1.Particvolu FROM Address1
>RIGHT JOIN table1 ON Address1.ID=table1.ADDRESS1_ID WHERE
>(((Address1.Inactive)=No) AND ((Address1.Particvolu)="Participant")) ORDER
>BY table1.VolName;
>
>I would like to use the combo box that comes from Combobox query, because
>I am using it for another macro on the same form.
>
>To answer your question What is in the field [Particvolu] It is a drop
>down box that contains either participant or volunteer.
>
>Maybe I could do something like.
>If (cboName) <> 0 and [address1.particvolu] = participant then
>Suggestions?


A field *is not a dropdown box*.

A field is *DATA* - text, or a number, or a date.

A dropdown box is not data; it's a *tool for displaying data*.

I'm still not at all clear what you're trying to do. What does it mean that
"cboName <> 0"? Is the user selecting a name from the combo box? If so does it
matter which name they select? If there are 8124 records in Address1 and you
ask if [address1].[particvolu] is equal to "Participant", and it is for 3489
of them and is not for the rest, what result do you want?
--

John W. Vinson [MVP]
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Export report to Excel, Error message "Compile Error: Argument not mc Microsoft Access External Data 0 16th Jul 2009 09:11 PM
VBAProject name compile error, not defined at compile time Matthew Dodds Microsoft Excel Programming 1 13th Dec 2005 07:17 PM
Compile error. in table-level validation expression. (Error 3320) =?Utf-8?B?RG9ubmE=?= Microsoft Access Forms 4 21st Mar 2005 08:13 PM
error message in Winword. ( Compile error in hidden module: AutoE. =?Utf-8?B?TXkgRXJyb3IgUHJvYmxlbQ==?= Microsoft Access Getting Started 1 4th Oct 2004 02:52 AM
excel 2003 error>> compile error in hidden module: ThisWorkbook clayton Microsoft Excel Misc 4 22nd Jun 2004 02:02 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 03:12 PM.