That is what I meant.
You're not really being forthcoming with details (or clarity). When you say
that's what you meant, was your code actually using AddItem and you get an
error? If so, telling us what the error is would be a big help. If you meant
that you used AddNew (and got an error, which you would) but meant to use
AddItem and when using AddItem everything is fine, well, then I guess the
problem is solved. For future reference, copy and paste your code from VB
into the message. This way, you won't make typos.

Signature
Mike
Microsoft MVP Visual Basic
> That is what I meant.
>
[quoted text clipped - 7 lines]
> >
> > That's because the method's name is AddItem, not AddNew.
Ed Wyche - 31 Jan 2005 04:39 GMT
Sorry about that.
No the problem is still not solved. I am trying to use the following code
to make it easier.
for i=1 to 10
cboTemp.AddItem rsTemp!Item & i
next
Instead of
cboTemp.AddItem rsTemp!Item1
cboTemp.AddItem rsTemp!Item2
cboTemp.AddItem rsTemp!Item2
etc.....
> You're not really being forthcoming with details (or clarity). When you say
> that's what you meant, was your code actually using AddItem and you get an
[quoted text clipped - 15 lines]
> > >
> > > That's because the method's name is AddItem, not AddNew.
Jeff Johnson [MVP: VB] - 31 Jan 2005 06:39 GMT
> Sorry about that.
>
[quoted text clipped - 11 lines]
> cboTemp.AddItem rsTemp!Item2
> etc.....
cboTemp.AddItem rsTemp("Item" & CStr(i))
Drop the ! syntax. It's ancient and inflexible, as this situation
demonstrates.
Ralph - 31 Jan 2005 07:47 GMT
Sorry Jeff, I didn't see your concise answer before responding myself.
-ralph
Compu-Pikachu - 31 Jan 2005 11:07 GMT
[JEFF JOHNSON] Drop the exclamation mark [or "point"] syntax.
[HOSHI PATRICIA FRIEDMAN] I never even knew that existed. Wow, it's amazing
what you can learn from this newsgroup without even asking questions of your
own!
Ed Wyche - 31 Jan 2005 16:49 GMT
I am getting and error as Type Mismatch
If Not rsTemp("AttractGraphic" & CStr(i)) Then arrAttractGraphic(i) =
rsTemp("AttractGraphic" & CStr(i))
>> Sorry about that.
>>
[quoted text clipped - 17 lines]
> Drop the ! syntax. It's ancient and inflexible, as this situation
> demonstrates.
Ralph - 31 Jan 2005 17:21 GMT
> I am getting and error as Type Mismatch
> If Not rsTemp("AttractGraphic" & CStr(i)) Then arrAttractGraphic(i) =
> rsTemp("AttractGraphic" & CStr(i))
What is the 'value' at the Field named "AttractGraphic'i'".
My guess you got burned by assuming vb would return the default property
'Value'.
Try
rsTemp( "AttractGraphic" & CStr(i) ).Value
or perhaps even
CBool(rsTemp("AttractGraphic" & CStr(i) ).Value )
You were warned. <g>
-ralph
Ed Wyche - 31 Jan 2005 18:55 GMT
I forgot to put a ="" in the If statement
>> I am getting and error as Type Mismatch
>> If Not rsTemp("AttractGraphic" & CStr(i)) Then arrAttractGraphic(i) =
[quoted text clipped - 10 lines]
> You were warned. <g>
> -ralph
Ed Wyche - 31 Jan 2005 18:55 GMT
Thanks for the info it worked.
>> I am getting and error as Type Mismatch
>> If Not rsTemp("AttractGraphic" & CStr(i)) Then arrAttractGraphic(i) =
[quoted text clipped - 10 lines]
> You were warned. <g>
> -ralph
Ralph - 31 Jan 2005 07:40 GMT
> Sorry about that.
>
[quoted text clipped - 33 lines]
> > > >
> > > > That's because the method's name is AddItem, not AddNew.
The "!" delimiter is short-hand for returning the value of the "named" item
in a Fields collection. It is convenient but quite specific.
In this context it replaces....
variantValue = rsTemp.Fields("Item1").Value
where "Item1" becomes an identifier and not subject to modification.
However, in the statement using ...
variantValue = rsTemp.Fields("Item1").Value, "Item1"is a string parameter
and can be modified before passing to the Fields Item method. So you could
use...
variantValue = rsTemp("Item" & CStr(i)).Value
Note that the default property of the Item Property is the current value so
you can leave the .value specification off, most of the time. But there can
be a problem, especially when passing an Item, that you end up passing a
reference to the Item and not necessary the value. (A la, "TextBox" vs
"TextBox.Text").
You can also use the position to specify a member of a Fields collection...
variantValue = rsTemp.Fields.Item(i).Value
variantValue = rsTemp.Fields(i).Value ' since the default is
an Item
hth
-ralph