Solved

Combo box selection to select records for form

Posted on 2009-05-15
11
633 Views
Last Modified: 2013-12-05
I have an ADP with SQL backend which was converted from Access. I had a combo box that worked in Access but it is not working since I upsized to the adp. Here is the After Update from the combo box.

What needs to be changed for it to work in the ADP?
Private Sub Combo144_AfterUpdate()

' Find the record that matches the control.

    Dim rs As Object
 

    Set rs = Me.Recordset.Clone

    rs.FindFirst "[fld_JobNumber] = " & Str(Nz(Me![Combo144], 0))

    If Not rs.EOF Then Me.Bookmark = rs.Bookmark

End Sub

Open in new window

0
Comment
Question by:afsfire
  • 6
  • 5
11 Comments
 
LVL 13

Accepted Solution

by:
bigbillydotcom earned 500 total points
ID: 24399551
shouldnt you declare rs as a recordset object?

Dim rs As DAO.Recordset

and command for cloning recordset is:

Set rs = Me.RecordsetClone
0
 

Author Comment

by:afsfire
ID: 24399594
Thats giving me Run-time error 13 Type Mismatch and doesn't clone the recordset
0
 

Author Comment

by:afsfire
ID: 24399614
Here's what I have after your suggestion

Private Sub Combo144_AfterUpdate()
' Find the record that matches the control.
    Dim rs As DAO.Recordset
    Set rs = Me.RecordsetClone
    rs.FindFirst "[fld_JobID] = " & Str(Nz(Me![Combo144], 0))
    If Not rs.EOF Then Me.Bookmark = rs.Bookmark
End Sub
 
is this correct?
0
 
LVL 13

Assisted Solution

by:bigbillydotcom
bigbillydotcom earned 500 total points
ID: 24399733
yes - that looks better
what line is it breaking on now?

this one look strnage
rs.findFirst "[fld_JobID] = " & Str(Nz(Me![Combo144], 0))
what is Nz ? a function?
and what about  this
rs.findFirst "[fld_JobID] = " & CStr(Nz(Me![Combo144], 0))
0
 

Author Comment

by:afsfire
ID: 24399918
Sorry but I'm not sure what Nz means...
it seems to be breaking on the
Set rs = Me.RecordsetClone   line
if I mouse over the rs it says rs = Nothing
0
U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

 

Author Comment

by:afsfire
ID: 24399947
i found someone else having the same problem but I don't understand the explanation of what the fix is. see below
Question:
I am migrating an mdb database to an adp/SQL Server platform. On one of my
forms, when a user selects a record from a list, selected fields for that
record are displayed on the form. In Access mdb, I do this with VBA code on
the after Update event for the list:

Private Sub List17_AfterUpdate()
' Find the record that matches the control.
Dim rs As Object

Set rs = Me.Recordset.Clone
rs.FindFirst "[primaryfield] = " & Str(Me![List17])
Me.Bookmark = rs.Bookmark
End Sub

THis doesnt work in adp. I gert an error message that says "Object doesn't
support this property or method."

If this is relevant, in the adp version, the List is populated by an SQL
view that the form is also based on (in the mdb version it was a query).

Do I need a totally differnt approach now, or can this VBA code be tweaked
to work?
Answer:
Split your .FindFirst into .MoveFirst and then .Find . ADO recordsets don't
have a .FindFirst method.

-using this info how would I transfer it to my code?
0
 
LVL 13

Expert Comment

by:bigbillydotcom
ID: 24400144
AHHH
the old ADo trick
gimme a few  - lemme do some quick dev
0
 

Author Comment

by:afsfire
ID: 24400157
I believe I found it... this seemed to work

Private Sub Combo144_AfterUpdate()
' Find the record that matches the control.
    Dim rs As Object
    Set rs = Me.RecordsetClone
    rs.MoveFirst
    rs.Find "[fld_JobID] = " & Val(Nz(Me![Combo144], 0))
    If Not rs.EOF Then Me.Bookmark = rs.Bookmark
End Sub
but I'll credit you half for your help okay?
0
 
LVL 13

Expert Comment

by:bigbillydotcom
ID: 24400375
not sure if u can change the points/credit after opening the question
but I'm here to help - not scour people for points
another thing you might want to consider is the Group Filter control
It does what you are looking for and is really easy to implement
To limit items displayed on a page, add a group filter control

To add the control, open the page in design view
then, using your right mouse button, drag the field containing the data you want to use as the basis for your filter from the field list (on the toolbar) to the data section of the page

When you release the button, Select Group Filter Control from the submenu

Access will create a combobox on the page
When you go back to data view, the page only displays the records that meet the filter

Good Luck!
0
 

Author Comment

by:afsfire
ID: 24400385
Thanks,
 
nahh don't worry about it... I just always appreciate the help. I'll look at the Group Filter Control.
Thanks again
0
 
LVL 13

Expert Comment

by:bigbillydotcom
ID: 24408731
thanks afsfire
0

Featured Post

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction The Visual Basic for Applications (VBA) language is at the heart of every application that you write. It is your key to taking Access beyond the world of wizards into a world where anything is possible. This article introduces you to…
Overview: This article:       (a) explains one principle method to cross-reference invoice items in Quickbooks®       (b) explores the reasons one might need to cross-reference invoice items       (c) provides a sample process for creating a M…
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

912 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now