Modules & VBA :: Empty Combobox Rowsource Returning ListCount Of 1

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 Replies


ADVERTISEMENT

Combobox Rowsource Per Row On A Subform

Dec 4, 2012

I've go a subform with 2 comboboxes. It's a datasheet view.

The combobox controls are called cmb1 and cmb2 for the sake of this...

cmb2 is dependent on cmb1. So when you select a certain value in cmb1, cmb2.rowsource should get updated to use a certain table.

But the kicker is that this should be on a per row basis. So if on row 1 of the subform datasheet you set

cmb1=Manager, cmb2.RowSource should get set to 'tblManagers'.

Then on the next row, cmb1 is set to Directors, cmb2.RowSource should get set to tblDirectors.

But the cmb2.rowsource on row 1 is still set to tblManagers.

View 2 Replies View Related

Refreshing Rowsource Query For Combobox?

May 18, 2005

Hi all,
I have a combo box which gets it's values from a table. It also has a where statement to filter the data given the value in another combo box. I.e.
SELECT DISTINCT Table1.some_field FROM Table1 WHERE Table1.some_other_field = Forms!frmSomeForm.Combo_box
The first time I change the value in Combo_box combo box it will filter the values in my other combo box. But when I change it successive times it doesn't refresh the query, so the same values stay. Any suggestions?

View 8 Replies View Related

Forms :: Setting Combobox Rowsource To Be A Recordset Instead Of Query?

Jul 15, 2015

I have a Product form that shows the details of each of the Products in my Product table. I also have a "Pick a product" combobox (who's rowsource is being fed by the same Products Query that feeds the form). This allows you to go straight to a particular product by selecting its name. So far, so simple.

I've since added a couple of combobox filters which use different columns ("Product Type" and "Collection") to allow the user to get down to a more manageable recordset to then work with.

Of course, because the "Pick a Product" combobox is being fed by the Products Query, the combobox can end up showing products that are not contained in a filtered recordset. This is... sub-optimal.

Is there a way of telling the "Pick a Product" combobox to use the products listed in the recordset as its rowsource rather than the product query? So that it only lists the products the user has filtered down to?

View 3 Replies View Related

Forms :: Error 13 When Setting Rowsource Of Combobox Using Union Query

Jan 18, 2014

I am trying to design an unbound combobox whose rowsource can be dynamically set based on a union query in order to search 1000's of names returning each name that contains a user defined string. The search does not start until the user defined string reaches 3 characters in length.

There are more details in the attachment but basically the vba code I used all saves OK in the vba editor but I get a runtime error 13 type mismatch when the code attempts to utilise the query to populate the rowsource of the combobox.

View 10 Replies View Related

Forms :: Combobox In A Form To List Values Of A Field In A Table - Rowsource

Apr 14, 2014

So I have a combobox in a form that lists the values of a field in a table. The rowsource is this:

Code:
SELECT [Estes Training Modules].[Training Module], [Estes Training Modules].[Period] FROM [Estes Training Modules] ORDER BY [Period];

The problem is that ALL values on that field show up, including repeated values. I only need each different value to show up once. How can I do that?

For example, what I get in the combobox is: Annual, 2-Year, Annual, Annual, 2-Year, 3-Year,...

What I need is: Annual, 2-Year, 3-Year,...

View 10 Replies View Related

Queries :: Listbox Filter Not Returning Empty Values

Jun 14, 2013

I have a form in which users can enter data in several textboxes to filter the listbox below it, this works great except for the fact that when a record lacks certain data it doesn't show up

Basically there are 4 filters, one for the name/id which works great, as the entries without id's show up just fine but this filter needs to be checked against the other 3 filters, for their group, education and type.

Lets use group as an example.

When a student has no group it should only show up when the group filter is an empty string. AFAIK the wildcards should see to that.

Currently however, when a student has no group, it doesnt show up at all unless I remove the | Like '*' & [groepFilter] & '*' | part from the query.

I've never used complicated WHERE's like this so it might be something very simple. I think I could get it to work using VBA and modifying the rowsource of the listbox from there but this would be a lot easier and I'm curious as to why this doesn't work.

The SQL:

SELECT Student.Studentindex, Student.studentid, Student.studentvn, Student.studenttv,
Student.studentan, Student.Groepcode, Opleiding.opleidingsnaam, Opleiding.type
FROM Student LEFT JOIN Opleiding ON Student.opleidingid = Opleiding.opleidingid
WHERE (((Student.studentid) Like '*' & [naamFilter] & '*') AND ((Student.Groepcode) Like '*' & [groepFilter] & '*')

[Code] ....

View 2 Replies View Related

Forms :: Formula Not Working - Empty Field Returning

Jan 31, 2014

I have a date in "date to engineering" of 13/ 01/2010 but I am not getting a value in my field which should be 1479 my field is just always returning an empty field

Code:
=IIf(IsDate([date to engineering]),"",IIf(IsDate([date from engineering]),Now()-[date to engineering],[date from engineering]-[date to engineering]))

View 4 Replies View Related

ComboBox Querying Table, Returning Null ?

Aug 8, 2005

Is anyone else experiencing similar problem ?

Basically here's what happen:

1. User need to look up item name, while in a subform. He pressed F5
2. A form showed up, with a ComboBox (which got its values from a query)
3. User chose an item name in the ComboBox, and then pressed the Close button
4. The item name got copied into the subform.

Problem is, for some items/records, step 4 doesn't happen :eek:
When I investigated, turned out that for some records, the ComboBox returned null (instead of the selected record)

This is on a 5800+ records table, on Access 2000.

Here's the code :

[Forms]![005_cashier].[subform_0051_enter_sold_items]!selling_price = Me!item_name.Column(2)
[Forms]![005_cashier].[subform_0051_enter_sold_items]!quantity = 1

The second line always works (always got copied to the subform properly), while the first one only works with certain items/records.

I've examined the offending records, but couldn't imagine how they'd be able to make Access to behave like that.

Any ideas ?


Thanks,
Harry

View 2 Replies View Related

Forms :: ComboBox Doesn't Display Some Values - Returning Blank

Feb 10, 2014

In a form used to record a sale for a company we have a dropdown box with the contact names for that company and when one is selected it populates other boxes like phone number etc however the combobox brings up all possible contacts but when some of them are selected all the boxes return blank, including the combobox, whereas most of the contacts work fine.

The SQL used for the combobox is as follows..

Code:
SELECT tbl_Contacts.ContactTelephone, tbl_Contacts.ContactMobile, tbl_Contacts.ContactEmail, tbl_Contacts.ID_Contact, tbl_Contacts.ID_Company, tbl_Contacts.Salutation & " " & tbl_Contacts.ContactForename & " " & tbl_Contacts.ContactSurname AS MainContact
FROM tbl_Contacts
WHERE (((tbl_Contacts.ID_Company)=[tbl_CompanyBookings].[ID_Company]))
ORDER BY tbl_Contacts.ContactForename;

Why some contacts work and some don't ??

View 7 Replies View Related

Forms :: Empty Combobox Values When Access Form Loads Vba

Feb 25, 2014

I want to empty the combobox every time when form loads. Using the below code

Quote:

Private Sub Form_Load()
combo1.RowSource = ""
End Sub

But Combobax is not emptying.

View 6 Replies View Related

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 9 Replies View Related

Modules & VBA :: Update RowSource In Subform

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

Modules & VBA :: RowSource Switch Using Toggle Button

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

Modules & VBA :: Reversing Rowsource Order For A Multicolumn Listbox

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

Modules & VBA :: Using Unbound Dropdown / Text Boxes To Narrow RowSource

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

Modules & VBA :: Returning A Value From Stored Procedure

May 11, 2015

I'm having an issue getting a return value from a stored procedure that I'm calling from VBA. This is what I have at the moment:

Code:
Dim strDate As String
Dim strWOStatus As String
Dim CurrentConnection As ADODB.Connection
Dim adoCMD As ADODB.Command
Dim adoRS As ADODB.Recordset
Dim ParamReturn As ADODB.Parameter

[Code] .....

The problem I am having is this error:
Error: 424
Description: Object Required

The line of code it errors on is:

Code:
Set .Parameters("@PartsUSedMTD").Value = ParamReturn

And the value of ParamReturn is always Null after it hits the line before it.

So it seems like it's not really creating the parameter variable SQL Server needs to run

View 4 Replies View Related

Modules & VBA :: DLookup Not Returning Any Results

Mar 26, 2014

Here is my VBA Dlookup Code:

Code:
Public Sub test()
Dim frm As Form
Set frm = Forms!StationLevelSummary

[code]...

At the bottom im printing the content of the controls which are on my form. These should return 1 number, but for some reason it does not. Ive used this code many times but I cant figure out why nothing is being returned.

View 4 Replies View Related

Modules & VBA :: Function Not Returning Argument

Jan 13, 2015

I have just added a function to a database to strip out any commas or quotation marks from a passed string.

However, it is returning a black string even though when I step through the function it creates the out string correctly and the variable "OutString" is populated when the Exit Function command is executed.

Calling code.
InString = Btxt
OutString = ""
Call Strip_String(InString, OutString)
SBtxt = OutString

[Code] .....

View 4 Replies View Related

Modules & VBA :: Like Function Returning Odd Results

Jan 13, 2014

I'm trying to do a string compare between two variables. One string variable is part of an array (which I'm looping through), the other is passed to the function as an argument.the function should return the position of a field in the OrderBy string of a subform.Here's the VBA :

Code:

Private Function SortPosition(strOrderBy As String, strField As String) As StringDim arrSortedFields() As String
Dim i As Long
If Len(strOrderBy) > 0 And InStr(strOrderBy, strField) > 0 Then
arrSortedFields = Split(strOrderBy, ",")

[code]....

The weird thing is, the line in blue returns True when, by watching the variables, it appears that it should not, and returns False when it appears that it should?

arrSortedFields(i) = "[RandomField]"
strField = "RandomField"
arrSortedFields(i) Like "[" & strField & "]*" = False
arrSortedFields(i) = "[SomeFieldName]"
strField = "ADifferentField"
arrSortedFields(i) Like "[" & strField & "]*" = True

I would have thought the expression "[RandomField]" Like "[RandomField]*" should return True?And similarly the expression "[SomeFieldName]" Like "[ADifferentField]*" should return False?Have been using 'Like' for donkey's years and never seen it throw results like this before?

(P.S. The reason I need to use 'Like' rather than a straight = is to account for the possibility that a field may be sorted descending, and therefore to nullify the DESC keyword which may follow any given field...)

View 9 Replies View Related

Modules & VBA :: Why Isn't Enum Returning Correct Value

Aug 7, 2014

I am using MS Access with SharePoint Lists and some Access Tables to generate reports in pre-formatted MS Excel Worksheets. My main module opens several classes. One of the classes receives a worksheet to keep in a historical book. This class can receive any one of several different types of pre-formatted worksheets. After all is said an done the class adds a cover sheet to the consolidated workbook and adds hyperlinks to the other sheets, kinda like a table of content.In the class I have the following in the general declaration.

code:
Public Enum BookType
A = 1
B = 2
End Enum
Private pBookType As BookType

Later in the class I have the following:

Code:
Public Property Let LoadBookType(ByVal btNewValue As BookType)
pBookType = btNewValue
AddWorkBook
End Property

in the main modual I have the following

Code:
classConsolidated.LoadBookType = A

When assigning the above property it passes in "11"

if I change it to the following

Code:
classConsolidated.LoadBookType = BookType.A

it passes in "1" as I expect and use in a Select Case statement later in the class.So why does one pass in "11" but the other passes in "1"?

View 14 Replies View Related

Modules & VBA :: Dir Function Empty For Certain Drives

Sep 17, 2014

I have a module for importing several excel files from a folder in Access. The user is prompted to select the folder which contains the Excel files.The issue:The code works fine if I select a folder from my company network drive (strFile variable returns with correct file name).The code does not work if I copy and paste the same folder to my desktop and select this location (strFile variable returns empty)

Code:

Option Compare Database
Private Sub btn_ImportData_Click()
Dim blnHasFieldNames As Boolean, blnEXCEL As Boolean, blnReadOnly As Boolean
Dim intWorkbookCounter As Integer
Dim lngCount As Long
Dim objExcel As Object, objWorkbook As Object
Dim colWorksheets As Collection

[code]....

View 7 Replies View Related

Modules & VBA :: How To Recognize Empty Field

Sep 24, 2013

Why can't I get this simple piece of code to work?

Code:
Private Sub txtDateBack_AfterUpdate()
' updates loan status
txtLoaned = 0
If txtDateBack = Null Then txtLoaned = 1
End Sub

Code:
Private Sub txtDateBack_AfterUpdate()
' updates loan status
txtLoaned = 0
If txtDateBack = "" Then txtLoaned = 1
End Sub

View 4 Replies View Related

Modules & VBA :: How To Check Empty Folder

Jun 12, 2013

I use code to check folder as below.

If the folder not exists, then create it.

If dir(myfolder) = "" then
mkdir(myfolder)
end if

How to add code to check empty folder, like below?

If dir(myfolder) = "" then
mkdir(myfolder)

else if empty(myfolder) then //there is no empty function in access
do something
end if

View 2 Replies View Related

Modules & VBA :: Empty Values In Array

Aug 16, 2013

I'm trying to store all the OrderNumber + Item combinations in 2 arrays and then because the OrderNumber column really contains 2 values I'm interested in, I split it up and store that column's values in 2 arrays. So in total, I have 3 arrays. An array for Item, an array for Order, and an array for RepId (which is the one that I split up from the OrderNumber column).

Anyways, when I print the RepId array with the ' MsgBox PostValCol1(x) ' It prints 4 values like it's supposed to. But when I tested it again by looping through the values and just doing a MsgBox, It goes for a long time and that's because it has a lot of empty values in that array. How to get rid of those empty values/not store them in the first place?

Code:

Set rop = CurrentDb.OpenRecordset("Select OrderNumber, ItemNumber From dbo_EntryStructure Where (ProductNumber = '" & txtPartNumber & "') AND (ActionCode = 'I')")

While rop.EOF = False
ReDim Preserve ArrRepOrder(j)
ReDim Preserve ArrItem(j)

[Code] .....

View 3 Replies View Related

Modules & VBA :: Dmax For Empty Table?

Apr 15, 2015

How do i use DMax() function instead of Autonumber, since the table is empty and it wont know what to do with Dmax() + 1 for next record?

E.g I have a new table Customer_details which contains

customerID
customerName
Age

now if i enter data through forms, i want the CustomerID to be incremental for each new record, so i can use Dmax() function. But since the table is empty how can i tell the form, through VBA that if it is null store 1 else store Dmax("CustomerID", "Customer_Details") + 1

View 2 Replies View Related







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