Modules & VBA :: Reset Rowsource For Comboboxes
Nov 18, 2014
I have a form with many comboboxes. The comboboxes need to have their original rowsource set to a table in my database. However, when the user selects a value in a combobox, it is programatically fed into a SQL string which serves to populate a subform. This part all works great.
However, I'm trying to reset the comboboxes as well so that options will "narrow down" until only a single option is possible. So far, I have:
Code:
Private Sub cmb_Author_Change()
Dim strSQL As String
strSQL = "SELECT tbl_Records.RecordName, tbl_Records.RecordDistinction, tbl_Records.Title, tbl_Records.Author, " & _
"tbl_Records.ProjectManager, tbl_Records.[Site Name], tbl_Records.ChargeCode,
[Code] ....
GetWhere() is the portion that feeds info from the comboboxes to the Finder string.
The red highlighted bit is the part I'm working on. Obviously, once I figure out the proper syntax, all of the other
comboboxes will be set up the same way.
What's funny is that in testing (all of the data currently input is simple and allows me to select options where I know what the response will be in other boxes), when I change Author and go to use cmb_RecordName, it replies that "the record source 'My Data' specified on this form or report does not exist" (where 'My Data' represents real data).
So, clearly, it is finding the data, just not using it as a record source, but rather believing that the name of the recordsource is the value.
View Replies
ADVERTISEMENT
Nov 15, 2004
I have a reset button that restores my combo boxes and list boxes to their default values.
I want the 'on click' event on the reset button to first clear all the existing values
before it resets them to their defaults. Does anybody know how can I do this?
The reason i need to know is because, if the user presses reset again, I get an error message because
those values are already inserted in their respective boxes. And since I'm using queries from tables as
the rowsources for these combo and listboxes, I get an error because it will not allow duplicate values.
Yes, it's true that I don't want duplicate values so i just want the values cleared first. , so that the
error doesn't have the chance to occur.
View 5 Replies
View Related
Jun 21, 2013
I would like to update the SQL for a subform. I have an SQL statement that I have placed into a string and now I would like to update the subform using it's RowSource property, but I get an error when trying to use the following statement:
Forms![frmModelSales].[frmModelSales-Subform-
QuestionableShip].RowSource = strSqlForSummary
(the message board has split this into two lines, it is really one)
View 3 Replies
View Related
Dec 4, 2014
I have a form that contains a combo box, I used the access wizard to make this combo box select a record from a table of customers and display that record on the form.
The user then has the option to print that record.
This works fine.
I now want to be able use the same combo box but with a different table so I can select Records from a list of suppliers.
Is there a way I could use a toggle button to change the rowsource of the combo box and then use that same combo box to select records from my supplier table.
View 2 Replies
View Related
Jan 17, 2014
I have a combo box which I define a SQL statement as its rowsource.
When I open the form, I have yet to define the SQL statement for the combo box.
My code is:
if me.cmbobox.listcount = 0 then
me.cmbobox.enabled = false
else
me.cmbobox.enabled = true
end if
But it shows the box as still enabled.
When I do debug.print me.cmbobox.listcount, it shows a value of 1. But that is impossible since I have yet to define a rowsource for it or its empty.
I also have column heading turned off too.
View 3 Replies
View Related
Dec 9, 2014
I have a 3 column list box in the format:
A1 A2 A3
B1 B2 B3
C1 C2 C3
The rowsource for this contains A1;A2;A3;B1;B2;B3;C1;C2;C3
I want to reverse the order so I have
C1 C2 C3
B1 B2 B3
A1 A2 A3
Which would give a row source of C1;C2;C3;B1;B2;B3;A1;A2;A3
View 10 Replies
View Related
Jan 23, 2015
I have 2 combo boxes on a form. The 2nd box is not visible unless the 1st box is set to a specific value (Illness). Once the specific value is set, the 2nd box appears with appropriate data for selection.
Goal #1:
I would like to have the form checked before it is closed to ensure that if the condition in box 1 is "Illness" then the 2nd box must have a value and can not be null.
Goal #2:
I am also having problems with the 2nd combo being visible when form opens or becomes current. The field is set to visible=false normally but needs to be visible when form opens if the conditions mentioned above are meet (true).
Private Sub Form_Unload()
If IsNull(Me.Incident_Classification) Then
MsgBox "Please select a type of Illness"
Me.Incident_Classification.SetFocus
]Code] .....
View 3 Replies
View Related
Feb 20, 2015
how I can get GotFocus and LostFocus of all comboboxes. See below the three codes (code 1, 2 and 3) that I've change from an example from the internet. But the problem is that the function "InitialiseEvents" is not running in these comboboxes. If I try the code 4 as an example, the function "InitialiseEvents" is running perfectly. I don't understand why I can't get GotFocus and LostFocus? You can to see two attachments:
Afbeelding1: The codes 1, 2 and 3 are running.
Afbeelding2: The codes 1, 2 and 4 are running.
Code 1:
Code:
Private Sub Form_Open(Cancel As Integer)
InitialiseEvents Me
End Sub
Code 2:
Code:
Public Function InitialiseEvents(frm As Access.Form)
Dim ctl As Control
For Each ctl In frm.Controls
With ctl
If .ControlType = acComboBox Then
.OnGotFocus = "=HandleFocus('" & frm.Name & "', '" & .Name & "', 'Got')"
[code]...
View 7 Replies
View Related
Jul 17, 2013
I'm developing a form to link a clause to one of a selection of internal documents from drop down boxes (of which there are a lot and hence looking for ways to make it more manageable to find).Now the setup of the internal documents is unfortunately beyond my control (separate SharePoint Libraries, inconsistent fields, you name it they've picked the worst way to do it :P).
I figure the best way to do this is to set up some unbound controls - two drop down (to narrow down location/department), two text boxes (doc code and name) with the idea that it will limit the selection to anything 'like' what is typed in.What I would like is either: How to set the RowSource criteria to only apply if the relevant control is not blank (i.e. if all the boxes are blank, all docs will show; if 'Sales' is selected in department and the user types 'Sales Order Entry' only the Sales Documents relating to order entry will appear)How to add criteria to the RowSource of a dropdown box via VBA (I've created the relevant 'If then ... else' statements but not sure how to add rowsource criteria in VBA)
View 2 Replies
View Related
Jul 8, 2015
I am running an export function from a module1 that contains a loop nested within a second loop. Each loop is running through items in a separate combobox on a single form1. The outside loop goes through combo1 items and the inner loop goes through combo2 items.
My issue is that the value of combo1 determines what items are available in combo2 (values are tied to tables). I can get the combo2 values to update when a user changes the values in combo1 (using requery in the afterupdate property of the combo1). However, I do not want a user to change the values, and the code module1 is ignoring the requery. How to force the combobox to requery through code in a module?
View 8 Replies
View Related
Sep 9, 2013
I'm making an accounts package.
I've made a graph of revenue by customer but due to the number of customers it's a bit hard to see the customer names.
So I would like to be able to select my own custom group of 5 customers to plot on the graph.
To do this I think I need a query that selects the 5 customers which is populated from 5 comboboxes on a new form that the user can select customer names from but I'm not sure of the VBA that links all this together.
View 2 Replies
View Related
Jul 16, 2015
We need to reset the autonumber after the last record is deleted.
For example:
2006
2007
2008
if 2008 gets deleted, we want the autonumber to reset back to 2008 rather than move to 2009.
Is this possible? This is the code we are using but cannot get the string to recognize the variable. If the variable is replaced with a number, it works, but it defeats the purpose of adding the plus 1 to the last autonumber.
Code:
Private Sub Command0_Click()
Dim RLMax As Integer
Dim Statement As String
RLMax = DMax("[id]", "Table1")
RLMax = RLMax + 1
strSQL = "Alter table table1 Alter Column Id Autoincrement(RLMax,1)"
DoCmd.RunSQL strSQL
End Sub
I realize we don't want to depend on the autonumber for anything other than a row identifier, but the table is setup that it is important for the rows to be sequential if the last record is deleted. Only if the last record is deleted.
View 12 Replies
View Related
Jul 10, 2014
I have this code to change user password
Private Sub Command3_Click()
If IsNull(Me.cboEmployee) Or Me.cboEmployee = "" Then
MsgBox "You must enter a User Name.", vbOKOnly, "Required Data"
Me.cboEmployee.SetFocus
Exit Sub
End If
[Code] ....
But it doesnt change the password....
View 3 Replies
View Related
Feb 28, 2014
I have a Microsoft Access database with SQL Server backend with 10000 records in my table, I have a autonumber field and in my database the purpose of the autonumber field is just to keep the record sequence (not to treat as a unique identifier) and I don't want to use a number field to manually enter the sequence. Whenever the record is deleted or the user won't save the record, it put gaps in the record sequence, Is there any way to refresh the autonumbers automatically "After delete confirm" event or "After Insert/update" even.
View 13 Replies
View Related
Jul 23, 2013
I'm using this control to allow users to select a date as input to a subform. The control is working just fine, but I have a problem, I need to reset the value to today on certain events (for instance a reset button to reset the values back to today). I have tried:
Me!calThru.Today
and
Me.calThru.Value = Date
and
calThru.Value = Date
but with no success.
View 4 Replies
View Related
Oct 25, 2013
I need to reset the autonumber each time I delete/append records in a table. Best way?
View 5 Replies
View Related
Aug 27, 2013
I have a database that will register the emails coming in and what time, also the time, date out and person.
I have a form with the fields to be filled in and a submit button. There are some fields that are automatically filled in and others need manually fill in.
below that part is a sheet (subform in the form of sheet) that should be filled in with the above data. Once it is there, it should empty the fields so they are ready to be filled in again. If I fill new data and press the submit button, it should go to the next available row.
View 2 Replies
View Related
Jun 21, 2005
Hi All,
I have a question:
I have 3 forms (a,b,c). Forms A and B are seperate forms and C will be activated by either A or B. The recordsource of C is a query which can be:
[forms]![formA]![text1] = Qr1
[forms]![formB]![text2] = Qr2
How can I write a code (or adjust it in the query) that that lets form C change it's rowsource in Qr1 or Qr2?
View 5 Replies
View Related
Jun 2, 2006
hi everyone,
i'm new to this forum.
I have a drop-down list that I want to populate from one of the columns in a table. But i want to do this with VBA, instead of building the query.
The reason for this is that I'm saving the project as an MDE file, and my database is residing in another *.mdb file. Thus the MDE file is just the executable version.
I can't seem to "read" the table without using VBA to do it.
Can anyone help me please?
thanks.
View 2 Replies
View Related
Jun 28, 2006
Hi,
I create the the combox in the form.
The Enter Event of the combox is
name.rowsource = "(select 'ALL' From [tbl]) Union (select [Name] from [tbl] Group By [Name] Order By [Name])"
The list solutions are:
Alan
ALL
Amy
Jeff
....
...
Can I put "ALL" in the first postion?
ALL
Alex
Amy
....
Because "ALL" means all the values.
I want to put "ALL" in the first place.
Thanks.
View 2 Replies
View Related
Jul 29, 2005
following problem:
1) a textbox gets value from a combobox
2) after selection in combobox value exists in table but isn't shown in textbox
until form is closed and newly opened
-> how do i requery so that the value that is existing is shown instantly??
View 3 Replies
View Related
Dec 5, 2005
I have the following code in the second combo box on a form
Me.cboReportType.RowSource = "select fldReportTypeID,fldReportType, fldFrom, fldTo, fldDue from tblReportType Where fldReportTypeID Not in (select fldReportTypeID from tblReport) order by fldReportType"
right now this code is filtering so that once a specific reporttype is used that specific reporttype does not appear again as a choice HOWEVER i need it to do this for a specfic record chosen in the first combo box...at this point once a reporttype is used for one record it does not appear again for any record -
the first combo box rowsource:
Me.cboProject.RowSource = "select fldProjectID,fldProjectNo, fldTitle, fldPurpose from tblProject order by fldTitle"
any help is appreciated
View 4 Replies
View Related
Jan 25, 2006
I know that for 1 column in a combo box you can say cboBox = a;b;c;d;e;f; But for my situation i need to have multiple columns... Does anybody know what the string should look like for multiple columns of values ?
View 4 Replies
View Related
Sep 22, 2004
I am trying to retrieve a record from a table (M_Paint) using a text box (txb_oldrecord) and a command button (cmd_getrecord). I want the record to show up on a list box (lst_display). I have written the following code:
Code:Private Sub cmd_getrecord_Click() With Me.lst_display .RowSource = _ "SELECT [M_Paint].[Old_Code], [M_Paint].[Supplier], [M_Paint].[Old_Color], [M_Paint].[Metallic], " & _ "[M_Paint].[Color_Number], [M_Paint].[Finish_Comments], [M_Paint].[Size], [M_Paint].[Number_of_Samples], " & _ "[M_Paint].[Project_Number], [M_Paint].[Date_Received] " & _ "FROM M_Paint " & _ "WHERE [M_Paint].[Old_Code] = '" & Me.txb_old_rec.Value & "';" End With End Sub
When I test this, I get the following error:
Quote: Data type mismatch in criteria expression.
What am I doing wrong?
Thanks in advance!
View 1 Replies
View Related
Sep 29, 2005
Ive posted similar in the forms section but it has gone unanswered so I've pulled out the offending query and hope someone here can offer insight into this frustrating problem.
I have a form [Training Record] that has 2 combo boxes.
Box A (course_title_combo) has the titles of the various training courses. It pulls 2 columns from the training_courses table, namely courseID and course_title. Only course_title is shown in the box. The control source of this is set to CourseID as this is the field to be written to the training_record table, showing who attends what course.
Box B (course_date_combo) is MEANT to pull through the dates that each course is on, by pulling through the course dates for each course where courseID (as selected by combo box A) is equal to the courseID in the course_dates table.
Here is the current rowsource query for box B - which is basically showing blank fields...
SELECT tbl_course_dates.course_date, tbl_course_dates.CourseID FROM tbl_course_dates WHERE forms![training record test form]!course_title_combo=tbl_course_dates.CourseID
I cant see what is wrong with the query, but Im guessing it must be wrong as it is the rowsource which determines what is included in combo box B.
Any help would be appreciated no end - im totally stuck now :(
View 8 Replies
View Related
Jan 10, 2006
Hi. Basically, I've been having trouble with this for a while now. I thought I got it working yesterday, but it turns out not. Here is the situation.
I have built a form that contains several combo boxes and a few text boxes for input. The user enters some or all of this information and clicks "Generate Report". Upon clicking this button, the form needs to launch a generic report that is populated with data using the search terms specified in the form. However, to add complexity, only certain parts of the SELECT and FROM clauses can exist depending on which options are completed on the search form.
I tried: DoCmd.OpenReport stDocName, acPreview, sqlQuery, whereCond
Where sqlQuery changed based on which settings were specified. However, this did not help because the actual query that belongs to the Report never seemed to change: sometimes it was missing columns.
I tried also to set rptNominationsList.RowSource = sqlQuery, but that also doesn't seem to work. On this one I get "Object required".
Thanks in advance!
Alex
View 5 Replies
View Related