Modules & VBA :: Passing Combo Box Control To Procedure
Nov 21, 2013
On my form I have a combo box where the user can select the sex of a person. I had set the row source of the combo to a table, tblSex and this works fine. Now I want to programatically add the table entries ( simply male or female) to the row source, having set the combobox to value list. I cant see how to pass the combobox and tablename parameters and I am getting an error on form load "The expression you entered as the event property setting produced the following error: UserDefined type not defined" The calling procedure from frmPeople is
I think the way the parameters combobox and tablename are passed is incorrect. I want to write a robust procedure which I can use for each of the comboboxes on my form.
I have a form displaying the contents of a table in a datasheet view. I want to click on a row and open up a new form that will use a field in the selected row as a parameter.
I know how to call the VBA procedure by setting the double click on field (Cant do it for click on any fields in the row?) and in the VBA was using:
strText = Me.[Product Reference].Value
to get the required value. However this only seems to work in single form view. If it is in datasheet view it gives an error and will not let you save the form.
I am guessing I am missing the row identifier in my VBA code.
Not sure which forum this was under, but I figure Access might be it
I have a stored procedure already written which works fine, if I supply the criteria to it before or at manual execution. I want it to use a field on a form in an Access Data Project as it's criteria (as a form is built off the results of the procedure). I can't find any documentation on how to pass criteria to a stored procedure for use in SELECT WHERE statements.
Can somebody point me in the right direction? Here is my stored procedure:
When i execute this manually I get the dialog prompt to enter the value for @parHomePhone, which is what I want to automatically pull from txtPhone on the frmSearch form.
The procedure call "Call RearrangeCoordinates(RearrangeCoords(), ReturnCoords())" return a message "Type mismatched: Array or user-defined type expected"Are there any views as to why the message is being displayed?
Private Sub CommandButton1_Click() Dim ReturnCoords As Variant Dim ........................................... ArrayLength = UBound(ReturnCoords)
I have just made a change to one of the forms by adding a button (by copying the only other button on the form) to cancel any changes and close the form. However, as soon as I added it I started getting the error message in the title. Please attachment LA Err1 for the full message. I also changed the caption on the other button on the form from "Close Form" to "Save && Close Form" this button is now giving the same error.
I have Compacted and repaired the DB on several occasions to no avail. I have deleted the procedures from the module and recreated them using the properties window - still get the error. I have deleted the buttons from the form and recreated the both via the object wizard and without it. Nothing I have tried has made any effect.
I have 3 Controls in a form, Control1, Control2, and Control3. Control2, and Control3 both have procedue under event OnDblClick, and I want to wirte code under Control1 OnClick to call OnDblClick of Control2 and then OnDblClick of Control3. Have try several ways but failed. It is another way besides copy whole procedure from OnDblClick into OnClick code?
I created an Event Procedure on the After Update event for a control in a continuous form. Basically, if certain conditions are met, I want it to disable another control. It works perfectly, except it is disabling the controls for all the records instead of just that record.
Does anyone know how to get it to just update that record? I've been researching and cannot figure it out!
I want to have a Combo Box on a form, that derives its values from a Table, but does not send selected values to another table. I want to use the value selected in the combo box in VBA code.I have set up a combo box, without a control source, and it shows the values in the drop down list but after I select one the box just goes empty. I expected that after selecting a value that value would be displayed in the combo box (and that would then become the value of the combo box that I could then use in code. I.e, CmdBox1.Value). If so, what do I need to do so that the value selected is displayed (and becomes the value of the combo box?).
I have a form that has several sub forms and what I want is that if the user chooses Plan Name in the main form "No Fault" or 'Workers Comp". I want message to pop and go to the field in the subform to enter data but I keep on getting an error.
Private Sub Plan_Name_AfterUpdate() If ([Plan Name] = "No Fault") Then MsgBox "Enter additional information in No Fault form before continuing." DoCmd.GoToControl ([NoFaultWCompsubForm]![Attorney Name]) End If End Sub
It says the action or method requires a control name argument?
I'm in the process of creating a database that allows users to enter details into a form which includes a date range as start and end dates.
I have used the inbuilt Calendar Control 10.0 control to allow users to select the date. It is linked to two combo boxes [cmbStartDate] and [cmbEndDate] using the following code (this code is repeated for each combo box):
Code:
Private Sub cmbStartDate_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
Set cmbOriginator = cmbStartDate
ocxCalendar.Visible = True
ocxCalendar.SetFocus
If Not IsNull(cmbStartDate) Then
ocxCalendar.Value = cmbStartDate.Value
Else
ocxCalendar.Value = Date
End If End Sub
And..
Private Sub ocxCalendar_Click()
''Update the ComboBox with the value entered into the ComboBox ''Put the value back into the relevant ComboBox cmbOriginator.Value = ocxCalendar.Value
''Hide the calendar cmbOriginator.SetFocus ocxCalendar.Visible = False
''Clear the variable Set cmbOriginator = Nothing
End Sub
This all seems to work fine- however, when I try to write the selected dates to a table or use them in a query they are not recognised (the form obviously needs to be open whilst the query runs), but if I manually type dates into these combo boxes these dates are picked up fine.
This is beginning to drive me mad so any help would be greatly appreciated.
I need to pass a criteria to a query from my option group control to my query.
It contains three options 1,2 and 3.
If option 3 then Pricing Type 1 and 2
How do I make the code below working?
IIf([Forms]![FrmUserSelection]![PricingType] Like 3,([dbo_AGPricingDiscounts].[PricingType])="2" Or ([dbo_AGPricingDiscounts].[PricingType])="1",",[Forms]![FrmUserSelection]![PricingType]")
I currently have a student membership database with a main Members form. When it opens it prompts me for a parameter which determines if only active, inactive or all members will be displayed. Once the form opens I use a combo box to search through all of the records. Currently this combo box lists all of the members names regardless of the parameter. To address this I set the same parameter query for the combo box. This works fine but it means that I have to enter the same parameter twice. What I would like to do is to have the 1st parameter, when the form opens, pass to the combo box. Any pointers would be greatly appreciated.
Also, if anyone knows of a more elegant way to accomplish this other than using a parameter query please feel free to pass this along.
I am having trouble getting information from a combo box to pass the data through some code.
The code is:
Private Sub ListBoxFind_AfterUpdate()
If ListBoxFind = 141 Then Me.FilterOn = False Else: Me.Filter = "[Assessment ID]= ListBoxFind" Me.FilterOn = True
End If
End Sub
I've tried Me.ListBoxFind, Me.ListBoxFind.Value, and ListBoxFind.Value. In all cases, a message box pops up asking for ListBoxFind (in this iteration) and then the filter works with the value I type in. It just seems that the value from the ListBoxFind never gets into the code. ListBoxFind is a combo box with four columns and the value bound to column 1.
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
This is a real conundrum. The following procedure works well the first time through but on subsequent times the database just goes into "Not Responding" mode and has to be restarted. I have tried putting delays in but with little success.
The idea of the procedure is to rename a query, "Daily Logs" to include a specific date "TransDate" so that when the query is sent via Outlook the Excel file name appears for example as Daily Logs 21-03-14.
I've been stumped for the past couple of days trying to discern a method for a form to determine that it's a new month and run a procedure and only run it on month change.
My initial thought is:
Open recordset move to the last record compare the month in a date field within the last record to the current month and run the procedure if the month is different.
I can't get this to work however and I'm not sure what I'm doing wrong. To be honest I typically fumble my way through VBA when it comes to opening recordsets. Here's what I got:
Code: Dim rs As DAO.Recordset Dim db as CurrentDB Dim strSQL As String Set rs = CurrentDB.OpenRecordset("FlightLog") strSQL = SELECT [txtDate] FROM [FlightLog]
[Code] ....
txtReqNumb and txtFltNumb are the values to be reset at the beginning of each month.
Am I on the right track and just have the VBA wrong?
I'm trying to put multiple IF statements into one procedure like the below:
Dim Answer As Integer Answer = MsgBox("Have You Selected The Correct Outcome?", vbCritical + vbYesNo, "Continue Request?") If Answer = vbYes Then 'Works fine here 'The bit I can't get right
I have 3 event procedure with 3 buttons to make them run.I would like to create another button that can run all procedures togehter. if I copy one of the procedures how do I tell it to run the other 2.
I have code for calling stored procedure with parameters,which is as follows
Dim qdf As DAO.QueryDef, rst As DAO.Recordset Dim IdValueToProcess As Long
IdValueToProcess = 221177 ' test data Debug.Print (IdValueToProcess) Set qdf = CurrentDb.CreateQueryDef("")
[Code] ....
And my stored procedure is
Code: ALTER PROCEDURE [dbo].[spItemDesc] @ItemNo varchar(200) , AS BEGIN set nocount on ; select ProductDesc1,ProductDesc2 from ProductDatabase.dbo.tblProductInfo where ProductNumber = @ItemNo END
I need to stop already ran procedure or function with vba code . So I use END command ans everything stops.. in some cases that is useful, but some times need I to do something else after I use END command, but after END everything stops...
LIKE THIS :
SUB () END ME.CTL.SETFOCUS 'OR CALL function EXIT SUB
I have a form with a button to print preview a report. This report needs one input parameter before executing. The computer this will run on is a touch screen and does not have a keyboard. Windows 7 has a "on screen keyboard" program. I want this to run first so that my user can input the parameter.
I have the following which throws an "Invalid procedure Call or Argument"
Sub CallTeclado() Dim RetVal RetVal = Shell("c:windowssystem32osk.exe", vbNormalNoFocus) End Sub