I have two check box controls on a form, and I would like to set some sort of validation rule to make sure that one of the boxes is checked before the form is closed. I also have many other forms with text, radio, etc. controls that I would also like to set the same rule for.
I've read some tutorials on this sort of thing, but I can't seem to piece it all together to achieve what I want.
I have a table Products that contains the fields Product, Size and Brand. I also have a form, frmProducts, that has a combobox linked to each of the fields in the Products table. I want to be able to select a product from the first combobox, tab to the Brand combobox and have only those brands associated with the product already selected.
This is how I think it should work: 1.ComboBox1 selects productA 2.ComboBox2 takes its options from a query that searches Products table for all instances of productA and displays all available brands. brandA is selected. 3.ComboBox3 get its options from another query that searches for all instances of productA that also have brandA and displays all available sizes.
What I'm having trouble with in particular is passing the data between queries. For example, I can't figure out how to tell the query to search for all instances of productA when its defined by the first combobox. Do I have to store it as a variable somewhere?
I am trying to use a combobox to select a value which then activates a query to return results.
Here is some details
I have to tables, one called "Customers" and the other called "Calls". These two tables are linked.
The customers is literally a list of customers with their contact details, but all I am in interested in is the "Company" Field.
The Calls table has a field called "End User" which looks up the company from the Customers Table.
What I am trying to do is create a search by Customer query, furthermore, I would like to do is to create a form with a drop down that looks up from Customers table, select the company and it returns all the records with that company...
What I have done
I have created a query that has the customer and calls tables included, I have dragged down the [Company] from customer table and then all the fields from the Calls table.
Then i created a blank form, inserted a combobox - Combo7, linked the box to the Customers table.
Back to the query, under the [Company] I have put into the criteria the following
Forms!sc!Combo7
Back to the form, selected the combo box, built a macro in the AfterUpdate, to run the query.
Tested this and it does not bring anything back, however if I put into the criteria Like [Please Enter Company Name], then typed the company name, it brings back all the records for that customer.
Am I missing something?, do I need to set the form control to the query, or even the combobox....
i have being requested to create a from that displays the number of files in different folders. I can accomplish this somewhat with the code below. In the example below it is only showing the code for the first 3 folders. I have 7 folders in total to count.
1.Each week the location of the data will change. In the example below it is showing 2014-W03, the following week it will be 2014-W04 etc. etc. I was thinking of having an input box in the form that the user type the date into, to trigger the code, but how would I go about changing the code to include this variable?
2.I need to repeat this code for 9 other products, so my form will be displaying data for 10 products in total. I know I could copy this code 9 times and modify it accordingly, but is it possible to loop it in some way?
Code: ' Returns the total number of fails Private Sub Form_Load() Dim file As Object Dim fileCount As Long With CreateObject("Scripting.FileSystemObject").getfolder(" estmachineProduct1 FAILS2014-W03") For Each file In .Files
Please could somebody point me in the right direction of code.
I have a database which I would like to query using a form with a combobox or two, each of which containing a list of eg. Customer Names, or Reference Numbers, which will then produce a report which can be printed out.
I know basic ADO, like get the database, open it, find records, update and delete records, however I have been unsuccesfully searching for the code to open a report, which will respond to certain sql parameters that correspond with the values in the combobox. And then be able to print that report if possible.
I would be much appreciative if anyone would point me in the right direction, Thanks!!
I have a Multiple Value Combobox that I have linked to one of my forms and I am trying to write some vba code that will allow on update, "if a certain item is clicked open up a different form".
Here is the Multiple Value Combobox Multiple value combobox3.JPG
I am making a dp for end of day sales, and i want to compare data in a table to the numbers inputted in a form and see whether this value is higher or lower. the table displays the target sales figures for each day, and the form allows the area mangers to enter in the current day figures.
i have two forms with a command button on the first which opens the other...
is there a way of getting this button to validate the primary key (i.e. make sure its not a duplicate) before it trys to open the next form??
i've tried to call the next record function (as the button seems not allow the next record to continue) but all this has done is delete the record and open the new form rather than stopping the action...
I have a form which allows an individual to add a cylinder record, i would like to validate the form in the sense that if the cylinder has already been added into the table it cannot be added again. So once the cylindernumber has been typed within the text field and the add button is clicked, the cylinder number typed is checked against the table if it has already been added a meesage should appear not allowing the user to enter a clyinder that is already added. I ahve tried this with the following code (the coding in red was already generated by adding a command button "add" to the form. The message i am recieving when the cylinder number in the textbox matches the cylinder number within the table is "you cant go to the specific record". I think my coding must be in the wrong order and IDEAS!!!!!
MyCode: Private Sub Command39_Click() On Error GoTo Err_Command39_Click
I have a main form called frmAF54. In this main form I have a subform named frmPassdown. The subform record source is from a table called tblCards. This table contains many different cards. I have a combobox called lstOpCard in the main form as well. The combobox lists all of the different cards in "tblCards". I have a button called "buttonFilter".
A user opens the form and clicks (or selects) the different cards in the combo box "lstOpCard" that they want to filter for. Once their selections are made, they can click the "buttonFilter" button and the subform "frmPassdown" will be filtered based off of their selections.
The filter is applied using the IN() function as shown below: Me.AF54PassDown.Form.Filter = "[OpCardID] IN ( " & sTemp & " )" --sTemp is a string containing the keyIDs of the cards selected.
My problem is that people will be opening and closing the form throughout the day / week. When the form closes, it loses the applied filter. How can I have my filter on the subform be saved after the form is closed and the filter is still applied when the form is opened later?
What i want is to have a combo box on a continuous form that as you type it filters the Query it is based on using a Like *. and drops downs so the user can see the updated list after each key press? Is this possible?
I have a subform in datasheet view for tracking calls from clients. The Client Name is a combination of the first and last name. I want to create a text box that allows me to start typing in the client name and it will filter for only those Clients that match. Currently, I have the following code (below) for the textbox, however when I start typing in a client name all the clients disappear from the table. The client name is in a combo box so I don't know if that is making a difference.
Private Sub Text3_Change() Dim strFilter As String Me.Refresh
Input box Search problem. I have been using the following to find a record in my frmMain using an Input Box:
Private Sub cmdClientIdSearch_Click() 'Searches for Client by ID number Dim rs As Object Dim strCriteria As String strCriteria = InputBox("Please enter Client ID" & vbCr & "Do not type leading zeros")
[Code] ....
It works great if I run it from a command button from frmMain. But, if frmMain is open and I run it from a command button on my switchboard, I get the following error message:
Run Time error 7951. You entered an expression that has an invalid reference to the Recordset Clone Property. I tried inserting a command to open frmMain in the first line, even before the two Dim statements, but I get the same result.
Hi, I've got a close button on my form as follows: Private Sub exitForm_Click() DoCmd.Close End Sub
In the beforeupdate event of the form I have have following code to validate the forms fields:
Private Sub Form_BeforeUpdate(Cancel As Integer) 'Place an asterisk (*) in the Tag Property of the text boxes you wish to validate. 'Then in the BeforeUpdate Event of the form, copy/paste the following:
Dim msg As String, Style As Integer, Title As String Dim nl As String, ctl As Control
nl = vbNewLine & vbNewLine
For Each ctl In Me.Controls If ctl.ControlType = acTextBox Then If ctl.Tag = "*" And Trim(ctl & "") = "" Then msg = "Data Required for '" & ctl.Name & "' field!" & nl & _ "You can't save this record until this data is provided!" & nl & _ "Enter the data and try again . . . " Style = vbCritical + vbOKOnly Title = "Required Data..." MsgBox msg, Style, Title ctl.SetFocus Cancel = True Exit For End If End If Next End Sub
This validation works fine up to a point. If I try to close the form and a required field is empty, I get a message box asking me to fill in the data. The problem is that when I click ok to the message, it shuts down the form, so I have to re-enter all the data again. My question is how do I prevent the form from closing after clicking ok on the message box?
I created a form for scheduling appointments on access 2013 using a youtube tutorial. I got most of it work apart from the combo box that functions in a way that once the time slot has booked with a client it should no longer be shown in the list.
E.g.:-2/2/2014 10:00AM is already booked with a client
The combo box should no longer display the 10:00 AM timeslot but can be shown on other days
Below is the VBA code that i typed out. How to create the code to make the combo box work in that manner.
Option Compare Database
Private Sub cboTime_Enter() Dim i As Date, n As Integer, oRS As DAO.Recordset, sSQL As String Dim dLowerbreak As Date, dUpperBreak As Date, dDuration As Date Dim dLowerPrecision As Date, dUpperPrecision As Date cboTime.RowSourceType = "Value List"
[Code] ....
I found out that the combo box does not work like it does in the video i.e the option does not dissaspear even though their has been a booking with that time slot with another client.
Coding that is required to make the combo box work like that or is their an error within the code that is preventing the combo box to work in such manner ...
I have a button that when clicked moves a piece of data to a subform. I have put the whole sequence below. The trouble I am having is :
- The event will not happen until the form is saved. I think this is because fkTaskID is a new record (auto) number which hasn't generated yet. - If I force the form to save it does work but then I get an error on the INSERT command when not all required fields of the form are complete (see sample in second part below).
Is there a way to save the record and maintain the integrity of the form input - and still have this code work?
BUTTON CODE ========== Private Sub BTNAddReasonRw_Click() Dim dIndex As Long DoCmd.SetWarnings False For dIndex = 0 To Me.LISTReworkReasonsUnselected.ListCount - 1
I need to create a field in an input form that is simply the concatenation of two other text fields. I have tried all sorts of things, but when I look at the data in the table that field.
I have a field called ID that I want to be created like this:
=Format([UniqueID],"00000") & "-" & [Mosque]
This works well in my output fields, but does not work the same way on the input form. It needs to be based on the currently input values from the current record. Anyone have any ideas?
How I could do a multiple value InputBox in VBA, if this is even possible... This is so I can prompt the end user to enter a range (with two string values as start and end parameters) for a report I'm working on.
If this is possible, I would like to include this as an additional parameter option within the code I have below:
Code:
Private Sub EmployeesBadges_Click() Dim soa As Byte Dim emp, sEB As String soa = MsgBox("Do you wish to print a single employee badge or all?", vbYesNo + vbQuestion) Select Case soa Case vbYes
I have a textbox where I need an afterupdate event, which should check that input is 3 letters followed by 3 numbers. The total is 6 characters, but always 3 letters + 3 numbers. If condition not met, a msgbox will be shown, for the user to input correctly, before being able to continue.
We receive hundreds of items at the time capturing the item barcode and the userID. I want to improve the process capturing the UserID once and updated the table with this entry on all empty records on the table. I have created the following script but I doesn't work.
Private Sub Command7_Click() Dim strSQL As String Dim strUser As String
strUser = InputBox("Scan your badge") strSQL = "UPDATE " & tblGER_ReceivingLog & " SET " & tblGER_ReceivingLog & _ "." & UserID & "='" & strUser & "' WHERE ([" & tblGER_ReceivingLog & "]. & UserID & is null);" DoCmd.RunSQL strSQL End Sub