473,378 Members | 1,578 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,378 software developers and data experts.

Open a form with record source from combo box

I want to select a Job Number and Revision from a combo box (cboSelectBOM).
I then want to open a form (frmBoM) and display the record for that Job
Number and Revision

When I double-click on the job in the combo box, I am running the following
code:

JobNum = cboSelectBOM.Column(0)
Rev = cboSelectBOM.Column(1)
DoCmd.OpenForm "frmBoM"

This derives the job number and revision from the combo box. How then, do I
pass this information to the form so that only that record is selected?
Dec 4 '07 #1
2 2151
"Bob Sanderson" <ne**@LUVSPAMbobsanderson.comwrote in message
news:Xn**********************************@69.28.18 6.158...
>I want to select a Job Number and Revision from a combo box (cboSelectBOM).
I then want to open a form (frmBoM) and display the record for that Job
Number and Revision

When I double-click on the job in the combo box, I am running the
following
code:

JobNum = cboSelectBOM.Column(0)
Rev = cboSelectBOM.Column(1)
DoCmd.OpenForm "frmBoM"

This derives the job number and revision from the combo box. How then, do
I
pass this information to the form so that only that record is selected?
Use the WhereCondition parameter in your OpenForm call:

strCriteria = "[Job Number]=" & JobNum & " And [Revision]=" & Rev
DoCmd.OpenForm "frmBoM", WhereCondition:=strCriteria

Note this assumes [Job Number] and [Revision] are your actual field names,
and that they sre both numeric. If one or both of them are type text then
surround the values with quotes, eg:

strCriteria = "[Job Number]=" & JobNum & " And [Revision]=" & Chr(34) & Rev
& Chr(34)
DoCmd.OpenForm "frmBoM", WhereCondition:=strCriteria

Dec 4 '07 #2
On Tue, 04 Dec 2007 17:16:58 GMT, Bob Sanderson wrote:
I want to select a Job Number and Revision from a combo box (cboSelectBOM).
I then want to open a form (frmBoM) and display the record for that Job
Number and Revision

When I double-click on the job in the combo box, I am running the following
code:

JobNum = cboSelectBOM.Column(0)
Rev = cboSelectBOM.Column(1)
DoCmd.OpenForm "frmBoM"

This derives the job number and revision from the combo box. How then, do I
pass this information to the form so that only that record is selected?
Depends. What is the datatype of the [JobNum] and [Rev] fields?
Number datatype?

Private Sub cboSelectBom_DblClick(Cancel As Integer)
DoCmd.OpenForm "frmBoM" , , , "[JobNum] = " &
Me![cboSelectBom].Column(0) & " And [Rev] = " &
Me![cboSelectBOM].Column(1)
End Sub

Then again, doesn't each record have it's own unique prime key
identifier? It should. Then all you would need do is include that
identifier field in the combo box (as a hidden value, bound column)
and just refer to that field. You would still show, in the combo box,
the JobNum and Rev fields for proper identification of the record.

DoCmd.OpenForm "frmBoM" , , , "[RecordID] = " & Me![cboSelectBoM]

A simpler method might be to simply filter the current form and
display just that record.

Me.Filter = "RecordID] = " & Me.cboSelectBoM
Me.FilterOn = True
--
Fred
Please respond only to this newsgroup.
I do not reply to personal e-mail
Dec 4 '07 #3

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

Similar topics

4
by: Andras Gilicz | last post by:
Hi VB fans I'm working on a relatively large project in VB6 with about a dozen forms, including graphs, labels, text boxes, etc. The software itself is actually a flow simulator with more or...
1
by: FZ | last post by:
Hi Gang, I was wondering if a generous person might be able to walk me through what I believe is a pretty simple task. I actually have significant Access experience, but I haven't done it in...
6
by: John | last post by:
Just a general question... I'm currently using a combobox that when updated, opens a form with its recordset based on a query using the combo box value as the criteria. I'm I correct in...
1
by: mikeybe | last post by:
Making a very simple library circulation database for a school project. I have a Patron Information table(patronID, first name, last name, phone) , an item information table (bookID, book title,...
8
by: Zlatko Matić | last post by:
There is a form (single form) and a combobox. I want that current record of the form is adjusted according to selected value in the combobox. Cuurrent record should be the same as the value in the...
1
by: Bill | last post by:
Problem: Combo box data disappears from view when a requery is done See "Background" below for details on tables, forms & controls On a form, I want to use the setting of bound combo box C1...
3
by: Cagey | last post by:
What I'm trying for: If this selection or if click on selection (highlighted line choice/ which ever selection change) w/in query's combo dropdown list box (on Switchboard), then Open in...
1
by: Captdreamer | last post by:
Hi there, As it will be very apparent in a moment, I am very new to Access and learning on the fly. (Much fun, but frustrating at the same time) I currently am trying to get a Combo Box that I...
1
by: pfm721 | last post by:
I know this is probably on the forum somewhere I was unable to find a solution because I didn't really know how to search for it. I have a form that has a combo box on it. The user types a # in the...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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?

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.