Combo Recordsource (dynamic)

Mar 2, 2005

Hello,

I have a combo box that i would like to dynamically change the recordsource (what values are available in the dropdown) based off of the criteria in another field. Basically, I want to switch which query the combo points to.

I am looking to do something like...

If field1 = nulll
combo recordsource = query1 (a list of values from table1)
Else
combo recordsource = quer2 (a list of values from table2)


I am looking to switch which query the combo is populated with, not limit the rows based on field1.

Any Ideas for this? Thanks!

View Replies


ADVERTISEMENT

Forms :: Combo Box Recordsource Requery

Jan 7, 2014

I have a recordclone combo box for navigating between 240 company records, so the form will go to the correct record on updating the combo. Instead of clicking on the down button and scrolling through the list, I would like to enter letters into the box and update the record source automatically as I enter them.

I'm not sure what events to use since there appears to be very subtle differences between them (eg between 'on dirty', 'on change' and 'before update').So when I type in 'T', only those companies that start with 'T' are viewed in the combo box.I have discovered the VBA 'dropdown' command which would be useful for the user.

Code:

company.dropdown
Table_Company
Company_ID: autonumber
Company_name: text

The name of the form is "form1" and the combo box name is "company".The record source for the combo box is "query_company". In the form the ID field is hidden and the company name is not hidden.The criteria I have for the combo would be something like this.

Code:

SELECT Table_Company.Company_ID, Table_Company.Company_name
FROM Table_Company
WHERE (((Table_Company.Company_name) Like [forms!]![form1]![company] & "*"));

View 3 Replies View Related

Forms :: Recordsource Does Not Exist - Combo Box Value Is Null

Mar 14, 2013

I am assigning a recordset using vbs code. The variable "CB_proj" is a combobox value. The problem comes when the combobox is null, the program errors out and even if I try to exit the routine with an if statement, it still compiles the line of code and errors out because the object doesn't exist. how I can get it to not compile that error if my combo box value is null?

CB_proj = Forms!CC_MAIN.CB_proj
strSQL = "SELECT " & [CB_proj] & ".* FROM " & [CB_proj] & ";"
Forms!CC_MAIN.projdat.Form.RecordSource = strSQL
Forms!CC_MAIN.projdat.Form.Requery
Forms!CC_MAIN.Form.Requery

View 3 Replies View Related

Dynamic Combo Boxes

Jul 31, 2006

I have a couple of combo boxes linked simply.

One is called brand and the other sub brand, and when i select a particular brand only the relevant sub brands are displayed. The problem i have is that when i reselect a different brand the sub brand combo box does not update.

I have created this setup by making the sub brand combo box a query.

The Query is:

SELECT SubBrand
FROM SubBrand.SubBrand
WHERE SubBrand.Brand=[Combo3]

Any help appreciated

Thanks in advance

View 5 Replies View Related

Dynamic Combo Boxes

Oct 27, 2006

I searched these forums but I did not see anything that was helpful in the matter, so if there is a thread like this please direct me to it and disregard this.

I have a combo box that houses the names of dealerships, this is bound to a table.

A user does have the ability to add a new dealership at all times to the combobox by simply typing it in.

The problem, the only way the new dealership appears in the list is if you close the form and reopen (which makes sense)

What I need to do is dynamically update this list so that anytime there is a new dealership it will automatically show up in the drop-down list.

Would a union query be the best way to go about this?

View 3 Replies View Related

Making Combo Box Selections Dynamic To Checkboxes

Mar 10, 2006

Hello people,

Say for example, in two fields within my dropdown for Camera Status in the Maintenance table...

FIT FOR PURPOSE - Availability Checkbox = Yes

What expression do I need in expression builder, so that Selecting UNDER REPAIR or FAULTY/DAMAGED instead makes the checkbox availability turn to unchecked automatically within a form, without the need to manually change the checkbox?

How do I do this?

Thank you.

Neil.

View 1 Replies View Related

Forms :: Update Table That Is Recordsource For Combo Box That Is Updating That Table

Mar 29, 2013

I have a combo box (cboManifestNumber) that is based on the following table:

tblManifestData
ManifestDataIDPK (autonumber PK)
ManifestNumber
RemovedDate
ManifestComments
TsdfIDFK (FK frm tblTSDF)

This table is related to:

tblTSDF
TsdfIDPK (autonumber PK)

I need to be able to update tblManifestData with a new manifest number and manifest comments, along with assigning it a TSDF. how to be able to enter a new manifest number and the associated data without having it create two lines in tblManifestData. I thought that I could enter a new manifest number, then requery the table and form so it shows the complete list of manifest numbers (including the recently entered one) while staying on the newest entry.

View 2 Replies View Related

Modules & VBA :: Adding Combo Box To Dynamic Multi Search

Jul 27, 2015

I stumbled on to a Dynamic Multi Search form on this site and have been tailoring it to my organization's directory of contacts. Everything was going good until I was asked to include a search by groups to which each individual may belong. The data in the table is contained in Yes/No check boxes for around 30 different groups. I am hoping to add a combo box to the Dynamic Search as a means to pull up individuals in any 1 category. Below are two attempts at what I thought might work, however, neither performs any filtering.

Code:
Private Sub Groupbox_Change()
Dim db As Database
Dim qdf As QueryDef
Dim strSQL As String
Set db = CurrentDb
Set qdf = db.QueryDefs("qryGroup")

[code]....

View 6 Replies View Related

Making A Dynamic Report From My Dynamic Form

Jun 30, 2006

I have a form that shows a list of all of my records in my database. I want to be able to click a button called "Report" and have that print a report that has all the records I have filtered on my form. I have a report in the format that i want it in, however, currently it prints every record and not just what is shown on my form. (The form is dynamic and I want the Report to be dynamically based on the form) HELP PLEASE!

View 6 Replies View Related

"Dynamic" Criteria For Combo-Boxes

Jun 14, 2006

Okay, this might be difficult to understand or tough for me to explain properly. Basically it's like this. I choose a cltContactID (a foreign key tied to a main Client's Contact's table). Then, in the next field, I'm choosing a source (for example: General Hospital) that referred the client to my company - call this refSource.

Then, in some cases, or most, I need to identify the person within that refSource that actually did the referring (eg, a Social Worker named Gene). Now I deal with 20+ Hospitals, 30+ Community Centres, 20+ Medical Centres, etc. etc., basically tonne of different sources.

So I would like the combo box, where I choose the person within a refSource that has referred a client, to only list people (or other staff personnel) that are affiliated with that source which I would have identifed one field earlier, rather than having a combo box that could potentially list hundreds and hundreds of names.

It's more complicated than just adding simple criteria in a query and making the combo-box look up that. The criteria must be dynamic; specific to each record.

Any insight?


Thanks,
Watson

I'm using Access2003 with WindowsXP. Thanks.

View 2 Replies View Related

Using Sql To Set A A Reports Recordsource

May 18, 2006

Using this code as part of a module to open a report in print preview and set it's recordsource to the sql I have written earlier in the code. The problem is when I run this it only prints the report it won't show it to me in print preview like I want. Anybody know what's wrong? Thanks...


DoCmd.OpenReport "SitesIssues_qry", acViewNormal, "", "", acNormal
Me.RecordSource = strsql & " " & strWhere & "" & strOrder

View 2 Replies View Related

Setting RecordSource In VBA

Jan 26, 2005

This is driving me mad. I'm trying to copy a table and form from a template.
They both copy fine, but when I try to change the new forms recordsource property, nothing happens.

Private Sub CreateQuiz_Click()
'copy structure from existing BLANK table
a = InputBox("Name of new table", "Create new Quiz")
DoCmd.CopyObject , a, acTable, "BLANK"

DoCmd.OpenForm ("BLANK")
Forms!BLANK.RecordSource = a
Forms!BLANK.Close
DoCmd.CopyObject , a, acForm, "BLANK"
Forms!a.RecordSource = a

End Sub

Any help would be much appreciated.

View 1 Replies View Related

Setting RecordSource

Jan 27, 2005

Hi All
I have a Main Form, This Main Form has a Subform, the SourceObject for the subform is another form.
What I am trying to do is to set the RecordSource for the SourceObject Form from within the code behind the main form so i can use the same form with various queries.
Appreciate any help - thanks

View 2 Replies View Related

Listbox Recordsource Value

May 27, 2005

How do I determine what value my listbox has?

Here is what generates the records from Form 2:

If Not IsNull(Me.[StartDate]) And Not IsNull(Me.[EndDate]) Then
strCriteria = strCriteria & "tblWO.Created Between #" & _
Format(Me.[StartDate], "m/d/yyyy") & "# And #" & _
Format(Me.[EndDate], "m/d/yyyy") & "#"

strSql = "SELECT DISTINCT [WOnumber],[Requested],[UDF1],[RequestedBy]," & _
"[Status],[property],[asset]" & _
"FROM tblWO " & strCriteria

Forms("frmFilter").Listbox1.RowSource = strSql

What I am trying to do is trigger a message box from the onclick of a command button on Form 2 and read the listbox # records on Form 1. It's gotta be something simple in my syntax. Search hasnt provided this scenario for me. I have tried these and more:

'If Forms("frmFilter").RecordsetClone.RecordCount = 0 Then
'If IsNull(Forms("frmFilter")).Listbox1 Then
'If Forms("frmFilter").Listbox1.RowSource = 0 Then
'If Forms("frmFilter").Listbox1.RowSource = Null Then
'If [Forms]![FrmFilter]![Listbox1.recordcount] = 0 Then
'If Forms("frmFilter").Listbox1.RecordCount = 0 Then
'If Forms("frmFilter").Listbox1.RecordCount = "" Then
'If Forms("frmFilter").Listbox1.RecordCount = Null Then

MsgBox "Sorry, no records meet your chosen dates. Change the dates and try again."

View 2 Replies View Related

Recordsource Of Subform

May 30, 2005

Hi everybody,
I have a form with its tabbed subforms' recordsource determined by the code:

Private Sub childTvl_Enter()

Me.childTvl.Form.RecordSource = "SELECT * FROM tblTvlInput WHERE tblTvlInput.Dept = """ & Forms.frmBudget.txtDept & """"

End Sub

This is to filter the huge data by department and only allowing the specified department to view their code. However, I find it slow and pesky as it only shows the required information when the user clicks on the child. I have tried putting the code above elsewhere but to no avail.

Is there a better way of speeding the filter as well as showing the user his own records when he clicks on the tab?

Thanks in advance. =)
You guys here are saviours!

View 3 Replies View Related

Recordsource Delima

Sep 26, 2005

I am trying to correctly code a Record Source value in a Form's 'On Open' Event . I first captured parm data from the calling Form, (Last Name, and First Name) to be used in the query as follows:

Private Sub Form_Open(Cancel As Integer)
Dim intI As Integer
intI = InStr(Me.OpenArgs, ";")
SearchFirstName = Left(Me.OpenArgs, intI - 1)
SearchLastName = Mid(Me.OpenArgs, intI + 1)
Me.RecordSource = "SELECT tblName.LastName, tblName.FirstName WHERE tblName.LastName = SearchLastName and tblName.FirstName = SearchFirstName"
End Sub

If I leave off the 'WHERE' clause, I get all the records in the table, so I am sure the syntax in that area is all wrong.

View 2 Replies View Related

Set Forms Recordsource

Nov 24, 2005

Is there a way to set the recordsource for a form before it opens? I've got Me.recordsource = "QryNewCaseForm" on the On Open event of the form but I toggle between recordsources once the form is open and if I close it while the recordsource is "QryCaseForm" it won't open as "qryNewCaseForm" the next time I open it.

View 2 Replies View Related

SubForms RecordSource

Oct 31, 2006

Today my client asked me to do something strange.

He wanted a field to be in the subform which was originally part of the parent form and is still part of the parent table.

(Hence, when I change the field in one subform line it would change for all other subform lines related to the current parent record) He insists to put this in the subform and it should be Editable there.

I accomplished this by basically putting a 'Parent table' join 'Child table' query in the subform so I could have access to this one field. Orginially I just had a query with the Child Table but to get access to that one field (and to make it editable) I made this extra join.

I don't like this design eventhough it works..... Any suggestions on how to effectively implement this.

Also I don't understand how Access still knows what to do using the Parent Link And Child Link fields (Located in the Subform Control). How does Access know to create a new record in the Subtable and not in the Parent Table when both are present in my subform's record source now.

View 1 Replies View Related

Change Subform Recordsource

Sep 4, 2006

I have a form with 5 tabs. Each tab has 2 subforms.
When the form loads I am trying to select it's recordsource by doing this:

Me!Subformname_A.RecordSource = "SELECT FieldA, FieldB FROM TableA WHERE"

However, it throws an error.
Is there something wrong with this ?

View 1 Replies View Related

RecordSource Change For Reports?

Sep 26, 2005

I have a report that can be used for 3 different queries. I've been trying for the last hour or so to get three different buttons on a form to open this report but give it an appropriate record source.
I figured there's got to be a way that's easier than three queries, and three reports...?
I was trying to use the same format as with forms :
[Reports]![rptReportName].recordsource = "qryQueryName"

or variations of that. Am I way off? It keeps saying that I've misspelled the name or it doesn't exist.

View 7 Replies View Related

Changing Navigation Recordsource To Query

Apr 10, 2006

Hello,

I'm trying to create navigation buttons that navigate in alphabetical order. I know that the easiest way to do this is by creating a query and using the query as the recordsource for my navigation buttons, but for the life of me I cannot figure out how to actually change to the recordsource to that query for only that navigation button.

I'd appreciate any help

Thank you
PRHC

View 2 Replies View Related

Changing Subform RecordSource Will Not Stick

Apr 18, 2005

Weird yet aggravating problem.

I am trying to setup a routine that will allow the user to change the RecordSource of a subform. The RecordSource is being changed yet once I move to another record the subform is reverting back to the original subform RecordSource. I am using the below command to change the subforms RecordSource...

Me.MySubformName.Form.RecordSource = MySQL
I even to make a copy of the subform and I changed the table it is linked to yet I got the same result

Me.MySubformName.SourceObject = "MyOtherSubForm"

There are no functions in the record selectors that would interfere with the subforms RecordSource.

Any suggestions as to why the RecordSource of my subform will not "stick" when I move to another record?

Thanks in advance for your help!

View 8 Replies View Related

Changing Subform's Recordsource With OnCurrent

Jun 29, 2005

Hi

I have problems working with a 3 level form

I have one main form called Projects

Depending on the record on the form Projects, the subform called Products will display the correct info

And on the OnCurrent event of the form Products, it will display the correct info for another subform called Product_Info

The problem is, the subform called Product_Info is dependant on a field on the Projects form, and on a field on the Products form so I cannot directly link the Product_Info form with either the Projects of Products form

What I'm doing is changing the recordsource of the Product_Info subform on the OnCurrent event of the Products subform but for some reason it won't work

If I display the recordsource of the Product_Info subform, it displays the right recordsource triggered on the OnCurrent event of the Products subform, but the data doesn't display

Thanks

View 3 Replies View Related

Field With Data From A Different Query Than RecordSource

Aug 31, 2005

I have a form that pulls data from a big joined RecordSource query. This form needs to be editable. I need to add a field on the form that will contain a value, which is actually the sum of numbers from several records. Because that sum value includes arithmetic in the query itself, I'm assuming that is why the results of the query are not editable. I tried joining the Query that gets that sum value into the main RecordSource statement, but because the sum Query is not editable, doing that renders the whole form uneditable.

I am new to working with Access forms, and VBA in general. I have a lot of experience using VBscript, though. I was asked to get this done and now I have to fight my way through it. I'm hoping there is maybe a way to write a function that will query for the sum value based on the current ID on the Form. The main form cycles through records, and the sum value is a total of points for the record shown in the form. So as each record loads into the form, I need to get the points total that matches that record's ID and display it. The points total does not need to be editable.

Any suggestions for a newbie on how to solve this?

View 2 Replies View Related

SubSubForm ControlSource/RecordSource Problem

Nov 4, 2005

I have a form with two subforms. One of the subforms has five subforms (subsubforms).

The ControlSource and the (query sequence for each) RecordSource of each of the subsubforms are created on-the-fly. The subsubforms have no Master/Child relationships specified. The subsubform merely display various filtered and various grouped subtotals of the 1st subform. Summing and grouping on the subsubforms prevents my using Master/Child properties.

On the AfterUpdate event on any of the filter fields on the form the ControlSources and RecordSources are rebuilt and the form becomes invisible for some reason and appears to hang, even after stepping through all the (class module) code with the debugger. Repeadedly clicking both Maximize and Restore buttons on the form's button on the Status Bar followed by clicking a 2nd form's toolbar icon causes the form to become visible under the 2nd form. The tool bar are also not visible, just a large brow bar at the top of the form. Moving the mouse over the toolbars causes individual icons to become visible or raised.

What am I missing?

Maybe I should calculate the values using DAO recordsets and backfill unbound subsubforms.

Thank you in advance for your thoughts.

View 1 Replies View Related

Change Recordsource In The Specific Form

Jan 15, 2006

Hi,

I want to write Visual Basic language in the form with one button:

I have one form named "setForm" with one button and one text box:
Let's set the new table "frm2", the new form "frm2"

Dim sql As String
sql = "SELECT [model].* INTO frm2 FROM [model]"
CurrentDb.Execute sql
DoCmd.CopyObject CurrentDb.Name, "frm2", acForm, "frm1"
Forms!frm2.RecordSource = "frm2"

The last statement code doesn't work: It is said that Microsoft Access cannot find the form "frm2" referred to in a macro expression or visual basic code.

How can I change the recordsource? Thanks.

View 1 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved