Modules & VBA :: Allow User To Change Default Checkbox Values?
Jun 20, 2013
I've got a form (frmEdit) that allows users to search tblMain for records using a bunch of unbound controls and a dynamically created SQL statement. Search results are displayed in a subform (subMain), and the current record in the subform is displayed in a set of bound controls on frmEdit.
Now the important bit: There is a set of unbound checkboxes on my form that allow the user to change which fields are visible in subMain. This is accomplished by the following:
Code:
Private Sub chkName_AfterUpdate()
If Me.chkName = 0 Then
Me.subMain.Form.CorrespondingField.ColumnHidden = True
Else
Me.subMain.Form.CorrespondingField.ColumnHidden = False
End If
End Sub
Certain fields are visible by default, but the user may want to change which fields those are. Here's what I've done so far to accomplish this:
Created a button (btnChangeDefaults) that opens a form (frmChangeDefaults)
Put checkboxes for each table field on frmChangeDefaults
Put a "Cancel" button (btnCancel)* and "Done" button (btnDone)** on frmChangeDefaults.
*btnCancel just closes frmChangeDefaults without making any changes to frmChangeDefaults or frmEdit
**btnDone changes Forms.frmEdit.Form.chkName.DefaultValue to Me.CorrespondingCheckBox.Value and then closes frmChangeDefaults
This all seems to work quite well, actually. Debugging confirms that the default values of the checkboxes on frmEdit are indeed changed when I click btnDone. But when I close frmEdit and re-open it, the default values return to what they were prior. This happens even when:
I close frmEdit using DoCmd.Close acForm, "frmEdit", acSaveYes
I close frmEdit after using DoCmd.Save acForm, "FrmEdit"
I save frmEdit manually by right-clicking and pressing save
Access 2010. I inherited a database that I need to copy and get it ready for next year's data. There are several places in the various tables where the default value on a field is 2013. I need to change to 2014. Any vba code or macro that I can do this without opening all the tables to change the values?
I have the following code which works perfectly BUT I want to be able to add another line of text if users enable a checkbox. I have tried everything I can think of but can't get it to work. When using an "IF check150" statement it just adds the extra text in regardless of selection or not.
Code:
Function Mail_Radio_Outlook6(activedoc As String) Dim OutApp As Object Dim OutMail As Object Dim strbody As String Dim acc_req As String Set OutApp = CreateObject("Outlook.Application")
[Code] ....
This is fine most of the time but If a user ticks check150 I want to add another paragraph.
Do I use an IF statement, if so in what format? is it a separate function etc?
I am slowly getting more familiar with Access but still come unstuck on the simplest of things at times.
I have a form with a subform where I want to select (via button) which format to open the form in. Opening the form is simple, DoCmd.OpenForm (FormName),acFormDS to open in datasheet, however, the subform opens in default view (single form). Can you programmatically set the property on the subform to change the Default View from Single Form to Datasheet and back?
I think my issue is that when the user opens my form a record gets created. Thus default value will not work. what happens is; the user fills out form 1 goes to form 2 and on form 2 i want a check box default value to be true...but its always false.
the checkbox in question is adequite staff. the user gets the question, "was there adequate staff" if there was the "adequate staff box" would be true. what i have tried is i created a "dummy" checkbox (checkbox299) entitle no. and labled adequite staff checkbox as yes. on the form2 open insert the following
Code: If Me.ADEQUATE_STAFF = False And Me.Check299 = False Then Me.ADEQUATE_STAFF = True Else End If
So I have a login system established with loginID, passwords, and different user types. I also have a User Change Password form. However, this form only allows the user to change their password to something new. Also, for some reason the form only allows the first user in the table (ID#1) to be changed regardless of who is logged in. I was using an embedded Macro. I need to be able to have the old password entered and verified before the password can be changed to something new.
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
I have been trying to create a login form that allows the user to change his/her temporary password logging it to the proper table along with timestamp and who done it info.But, after spending the morning trying to find the proper syntax I am flummoxed.
I can get everything to work accept the update of the fields. I can get the command to work (writes to the location) but it does the pop-up what is the parameter thing when it works. I have all the information just need to get it in so the command recognizes it.
DoCmd.SetWarnings False DoCmd.RunSQL "UPDATE lut_TeamList SET Pass = txt_Password.value WHERE TeamListID = Me.cbo_UserName.Value" DoCmd.RunSQL "UPDATE lut_TeamList SET UpdatedBy = Me.cbo_UserName.Value WHERE TeamListID = Me.cbo_UserName.Value" DoCmd.RunSQL "UPDATE lut_TeamList SET UpdatedWhen = Now() WHERE TeamListID = Me.cbo_UserName.Value DoCmd.SetWarnings True
Be gentle with me, for I am new, I can't write code, my database is all done by macros etc.
I have created a subform which incudes a yes/no checkbox. I want this to default to 'checked'. The subform is used to record an audit of the position of valves. It is based on a query combining two tables, one containing valve details and the other the results of the audit. I have set the default value for this field as '-1' in the audit results table, and also in the subform checkbox field. However whenever the query is run, the subform contains a list of valves with thier checkboxes stubbornly unchecked. How can I make the query return a list of valves with the checkbox ticked?
I have the following VBA code that auto populates a word template:
Private Sub Command24_Click() On Error GoTo ErrorHandler: ErrorHandler:
[Code].....
The code executes flawlessy but there are three values that are based off check boxes set as YES/NO (EMPLOYEDATREGISTRATION, EMPLOYED and FRINGEBENEFITS). These values show up as -1 for YES and 0 for NO.
Is there anyway to add code to mine that would allow me to change these values before they are sent to the Word template?
I am trying to write a code that will execute at the change even of the combobox/Listbox and when a character is typed in it then all the data from "DocumentType" field whose first character matches with the first character typed in Combo/Listbox will be stored in it.
The following code doesn't work:
Private Sub ComboBox4_Change() Dim strText, strFind As String strText = Me.ComboBox4.Text If Len(Trim(strText)) > 0 Then strFind = "BarcodeRef like '" & strText & "*'" End If
I'm having trouble viewing values that exist in table 'tblTest2' to the user. The first set of code (below) doesn NOT work. Yet the second set of code (all the way at the bottom) DOES work. And by work I mean that it erases the old values and only puts the tblTest2's new values. The first set of code has values but they are not the right ones. The second set of code has the correct values for its statement...
Code:
strTable = "tblTest2" 'Table for storing values for viewing purposes DoCmd.DeleteObject acTable, strTable 'Delete tblTest2 old values CurrentDb.Execute "CREATE TABLE tblTest2 " _
In Access 2010 I have a Data Entry Form on which I have an unbound textbox in the header that the user can put a default date in. In the body of the form is a bound textbox that records the date and the default value is set as =defaultdatestat (obviously the name of the box in the header).
Problem: The default date shows up perfectly until a value is put in any of the other text boxes.
For further info : If you put values in text boxes default value disappears; if you then push escape the default value reappears when the values in the text boxes disappear.
I have several forms that each has a dozen or more checkboxes, true/false. I want to be able to change the background color of the label of each checkbox depending on if the checkbox is true or false. I have used the following code which works great:
If Me.A = True Then Me.lblA.BackColor = vbYellow Me.lblA.BackStyle = 1 Me.lblA.ForeColor = vbRed Else Me.lblA.BackColor = vbWhite Me.lblA.ForeColor = vbBlack End If
Me.A refers to T/F checkbox A and Me.lblA refers to its label. This is repeated for each of the checkbox controls. If the control is [B], then its label is lblB. I have used this in the form OnCurrent event and the checkbox control OnUpdate event. I was wondering if I could use the tag property to this, saving me writing countless lines of code and having the OnCurrent event of each of the forms so long and cumbersome. And I do know that I can use conditional formatting to do this, but I would prefer not to use that method. Is there any way to do this using the tag property and not so many lines of code?
I have a checkbox on my form that basically deletes a record when the user ticks the checkbox. What I want to know is how do i check whether the person is "ticking" or "unticking" a checkbox before any action is carried out?
Hi i followed the link below http://support.microsoft.com/kb/179371 and was successful to put the password on my form. my question is how do i change the default password to my own. i have tried but failed. Any help will highly aprreciated
IT guy quit. New forms printer installed and unable to relate/find form or query that default printer is pointing to to change to new printer. Non programmer. Clueless. program is 10MB and database is 2.3MB searched through forms/reports/ and queries. too much **** to look at
I have tried to change the default database with the tools options general tab. I type in the change and it sticks as long as I do not get out of Access. However, once I do get out it goes back to the old default selection. How can I make this stick??
I have a column for default value of today's date "Date()". In the next column there is formula for no of days which calculates as
No. of days = ([Today's Date] - [Audit Date]/7*5 (/7*5 excludes sat and sunday).
My problem is that default value of date does not change as i open the table everyday. I know why. Coz i introduced the date column after 200 records already entered.
Now today's date only changes if new record is inserted.
How to get current today's date everyday automatically ? when we open the database next day !
note that I am using Today's date only for calculating number of day's formula. otherwise no function of this column.
Hi I have tried to look, but have not find the solution:confused:
I have a form wich I need in certain fields to have a default value, and this needs to be changed from the final user, I was thinking about taking the data from the previous input, the final user will use the control panel were there is a "push button" to open the form in add mode. Can I get some help:D
I curently have a query based on a payments table. In the payments table there is a field called date (when the payment was processed).
I want to be able to display, in my query, the quarter that this payment was made in. It is based on financial quarters so quarter 1 starts on April the 1st.
The default of firstweek seems to be January the 1st. Can I change it to April the 1st - if so how?
I've tried to change the default of a yes/No field so that it's either NUll or "" or Yes. This has proved unsuccessful and all the fields are still showing as No for default unless I obviously select Yes
Does anyone know if there is a way to change the Default of this field to either Yes or so that there is Null?