473,407 Members | 2,629 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,407 software developers and data experts.

Combo Box Problem

I have a table (tblPhone) with text fields FULL, LAST, PHONE,

I also have a combo box (cmboFull) .
The row source for cmboFull is SELECT DISTINCT [FULL] FROM tblPhone;

Here's the code for the combo box

Private Sub cmboFull_AfterUpdate()
' Find the record that matches the control.
Dim rs As Object
Set rs = Me.Recordset.Clone
rs.FindFirst "[Full] = '" & Me![cmboFull] & "'"
Me.Bookmark = rs.Bookmark
This combo box populates ok but when I click on any item in the combo box I
get the following error on the "Set rs = Me.Recordset.Clone" statement.
Run time error '91'
Object variable or Withblock variable not set.

I used similar code in another program and it worked fine so I am puzzled
why it fails here.

Any ideas

The overall objective is to present a combo box containing the data in the
FULL field and
then set a couple of text boxes with the LAST and FULL fields in the
selected record.
Jun 5 '06 #1
3 2842
Try without the 2nd dot, i.e.:
Set rs = Me.RecordsetClone

There are several other things that could go wrong with that code, including
reference priorities, the need to test NoMatch, and weird messages if the
record cannot be saved to activate the move (e.g. "Cannot Update without
Edit first".) For an example of a FindFirst that takes care of these issues,
see:
http://allenbrowne.com/ser-03.html

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"RICHARD BROMBERG" <no*****@att.net> wrote in message
news:YT********************@bgtnsc05-news.ops.worldnet.att.net...
I have a table (tblPhone) with text fields FULL, LAST, PHONE,

I also have a combo box (cmboFull) .
The row source for cmboFull is SELECT DISTINCT [FULL] FROM tblPhone;

Here's the code for the combo box

Private Sub cmboFull_AfterUpdate()
' Find the record that matches the control.
Dim rs As Object
Set rs = Me.Recordset.Clone
rs.FindFirst "[Full] = '" & Me![cmboFull] & "'"
Me.Bookmark = rs.Bookmark
This combo box populates ok but when I click on any item in the combo box
I
get the following error on the "Set rs = Me.Recordset.Clone" statement.
Run time error '91'
Object variable or Withblock variable not set.

I used similar code in another program and it worked fine so I am puzzled
why it fails here.

Any ideas

The overall objective is to present a combo box containing the data in the
FULL field and
then set a couple of text boxes with the LAST and FULL fields in the
selected record.

Jun 5 '06 #2
Allen

I changed the code, removing the 2nd dot as you suggested, but that
generated the following error:
"You entered an expression that has an invalid reference to the
RecordsetClone property"

What else could be causing it.
"Allen Browne" <Al*********@SeeSig.Invalid> wrote in message
news:44***********************@per-qv1-newsreader-01.iinet.net.au...
Try without the 2nd dot, i.e.:
Set rs = Me.RecordsetClone

There are several other things that could go wrong with that code, including reference priorities, the need to test NoMatch, and weird messages if the
record cannot be saved to activate the move (e.g. "Cannot Update without
Edit first".) For an example of a FindFirst that takes care of these issues, see:
http://allenbrowne.com/ser-03.html

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"RICHARD BROMBERG" <no*****@att.net> wrote in message
news:YT********************@bgtnsc05-news.ops.worldnet.att.net...
I have a table (tblPhone) with text fields FULL, LAST, PHONE,

I also have a combo box (cmboFull) .
The row source for cmboFull is SELECT DISTINCT [FULL] FROM tblPhone;

Here's the code for the combo box

Private Sub cmboFull_AfterUpdate()
' Find the record that matches the control.
Dim rs As Object
Set rs = Me.Recordset.Clone
rs.FindFirst "[Full] = '" & Me![cmboFull] & "'"
Me.Bookmark = rs.Bookmark
This combo box populates ok but when I click on any item in the combo box I
get the following error on the "Set rs = Me.Recordset.Clone" statement.
Run time error '91'
Object variable or Withblock variable not set.

I used similar code in another program and it worked fine so I am puzzled why it fails here.

Any ideas

The overall objective is to present a combo box containing the data in the FULL field and
then set a couple of text boxes with the LAST and FULL fields in the
selected record.


Jun 5 '06 #3
Is this a bound form, i.e. does it have something in its RecordSource
property?

If the source is an Access table (or a query or SQL statement that uses
Access tables), you may need to change the declaration of:
Dim rs As Object
to:
Dim rs As DAO.Recordset
and make sure you have a reference to the DAO library. The reference is
present in all versions of Access except 2000 and 2002, so if you are stuck
on one of those versions, see:
http://allenbrowne.com/ser-38.html

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.
"RICHARD BROMBERG" <no*****@att.net> wrote in message
news:kO*********************@bgtnsc04-news.ops.worldnet.att.net...
Allen

I changed the code, removing the 2nd dot as you suggested, but that
generated the following error:
"You entered an expression that has an invalid reference to the
RecordsetClone property"

What else could be causing it.
"Allen Browne" <Al*********@SeeSig.Invalid> wrote in message
news:44***********************@per-qv1-newsreader-01.iinet.net.au...
Try without the 2nd dot, i.e.:
Set rs = Me.RecordsetClone

There are several other things that could go wrong with that code,

including
reference priorities, the need to test NoMatch, and weird messages if the
record cannot be saved to activate the move (e.g. "Cannot Update without
Edit first".) For an example of a FindFirst that takes care of these

issues,
see:
http://allenbrowne.com/ser-03.html

"RICHARD BROMBERG" <no*****@att.net> wrote in message
news:YT********************@bgtnsc05-news.ops.worldnet.att.net...
>I have a table (tblPhone) with text fields FULL, LAST, PHONE,
>
> I also have a combo box (cmboFull) .
> The row source for cmboFull is SELECT DISTINCT [FULL] FROM tblPhone;
>
> Here's the code for the combo box
>
> Private Sub cmboFull_AfterUpdate()
> ' Find the record that matches the control.
> Dim rs As Object
> Set rs = Me.Recordset.Clone
> rs.FindFirst "[Full] = '" & Me![cmboFull] & "'"
> Me.Bookmark = rs.Bookmark
>
>
> This combo box populates ok but when I click on any item in the combo box > I
> get the following error on the "Set rs = Me.Recordset.Clone" statement.
> Run time error '91'
> Object variable or Withblock variable not set.
>
> I used similar code in another program and it worked fine so I am puzzled > why it fails here.
>
> Any ideas
>
> The overall objective is to present a combo box containing the data in the > FULL field and
> then set a couple of text boxes with the LAST and FULL fields in the
> selected record.

Jun 5 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Heather | last post by:
Hi I am desparately looking for advice in relation to storing the results after selecting items from two combo boxes on a Referral form. The first combo box 'ctl Type' displays a full list of...
1
by: Jeff Smith | last post by:
Hi This is a repost due to no responses Here's a problem I've encountered with Access 2003 which has got me to redesign how I get the row source in a second combo box using the first combo...
9
by: Edwinah63 | last post by:
Hi everyone, Please let there be someone out there who can help. I have two BOUND combo boxes on a continuous form, the second being dependent on the first. I have no problem getting the...
7
by: Ausclad | last post by:
Ok, ill try again..... It seems fairly simple. I have two combo boxes in a datagrid. The datagrid is bound to a a table in a dataset. The two combo boxes are bound to a single data table...
1
by: lawton | last post by:
Source: this is an access 2003 question My knowledge level: reading books, internet, and trial & error; no formal training I'm trying to get a running sum of what's filtered in a subform which is...
4
by: Dave | last post by:
I wasn't sure how to search for previous posts about this, it felt real specific. Ok so here's the database & problem: I have 4 combo boxes: cboServer, cboPolicy, cboDB, and cboApplication. ...
2
by: biganthony via AccessMonster.com | last post by:
Hi, I decided to install Office 2003 Service Pack 3 on my home computer to test (in full knowledge that there may be some issues with it). After installation, I have noticed that with a small...
3
rhitam30111985
by: rhitam30111985 | last post by:
Hi all.. i am trying to create a combo with the pop down list being modfied in real time as i type each character : import gtk window=gtk.Window(gtk.WINDOW_TOPLEVEL)...
6
by: =?Utf-8?B?amVmZmVyeQ==?= | last post by:
i need help with a combo box and this same code works on my first tab with a combo box. The error or problem i have is this code causes an index out of range error when i run it on my second combo...
3
by: evenlater | last post by:
Using Access 2007, I've found that combo box back colors change to transparent from normal inconsistently for no reason I can discern. Never had that problem in previous versions of Access. I do...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.