access-vba

Creating an array in VBA based on two array fields

我们两清 提交于 2020-01-06 06:51:11
问题 I have a couple tables with lookup fields that point to the same data in a third table, and both fields can select multiple values. A user can select a record from each table, and I need to be able to separate out the overlapping values in VBA. To do this, I've tried creating a third array in VBA into which I'll dump the resulting values, but I'm getting a Type Mismatch error. I can't seem to find a reason that this would occur. The code, reduced as much as I can without losing the sense of

MS Access ToggleButton Picture change

五迷三道 提交于 2020-01-06 06:46:16
问题 I was wondering if it is possible to change the picture of a toggle button in Access VBA depending on the state of the toggle button (pressed and not pressed)? My previous attempt on doing it included a check if the button's value is "true", but it hasn't really produced a valid result. If Me.Toggle4.Value = True Then Me.Toggle4.Picture = "IMAGE" Else Me.Toggle4.Picture = "IMAGE" End If What the code above produces is the button always having the same image. 回答1: It appears that the code

storing code in a column and using it

北城以北 提交于 2020-01-06 06:06:00
问题 I have a column that has data, such as year(date) or date-365 . How do I use this text as code, not as text? Meaning, I'd like to be able to do something like me.ProjectName="ddddd " & MyColumnWithCode and get ddddd 2017 or ddddd 10/21/2016 I did google in every way I could think of and didn't get anything. 回答1: You can use: Me.ProjectName="ddddd " & Eval(MyColumnWithCode) but not with your present code. It has to read: Year(Date()) Date()-365 回答2: Simply write dddd = sheets("Sheet1").range(

How can a reference fields on an Access form using a variable?

不羁的心 提交于 2020-01-06 03:18:40
问题 I have 20 text boxes on an Access 2010 form called [P101] to [P110] which refers to fields [P101] to [P110] in the source table. The may contain a value or not, but if not I do not want to see them. I also have a field [UsedFields] in the table which has counted how many of the fields are in use. In Form_Current I can set the following code but is there a way I could set a FOR NEXT loop to use a variable for the Field Name? The current code (which works but is very clumsy) is: If UsedFields >

How can a reference fields on an Access form using a variable?

戏子无情 提交于 2020-01-06 03:18:14
问题 I have 20 text boxes on an Access 2010 form called [P101] to [P110] which refers to fields [P101] to [P110] in the source table. The may contain a value or not, but if not I do not want to see them. I also have a field [UsedFields] in the table which has counted how many of the fields are in use. In Form_Current I can set the following code but is there a way I could set a FOR NEXT loop to use a variable for the Field Name? The current code (which works but is very clumsy) is: If UsedFields >

VBA ActiveDocument Concerns / Alternatives?

匆匆过客 提交于 2020-01-06 02:28:08
问题 I'm using VBA in access to open up a protected word template, fill in the data, and then re-protect it.... this way, if the database system goes down, the word template can still be used manually in its protected state. I have just started using VBA and in this line: If ActiveDocument.ProtectionType <> wdNoProtection Then ActiveDocument.Unprotect Password:="" End If I'm concerned that whilst running the code in access, that if the user opens up another word document and makes it the focus,

Run Time Error 5 when initializing a 2D array

我与影子孤独终老i 提交于 2020-01-05 09:27:13
问题 I have been initializing a 2D array using Arr=Array(Array(),Array()) . But I have found that a Run Time Error 5 - Invalid Procedure Call or Argument would be triggered. The code have been used for years and the problem arose yesterday so I think it may be the result of some of the updates for MS Office or Windows. Update: The Error exists for Windows 10, Windows 7 but NOT for Windows Vista. To reproduce the Error: Sub foo() Dim Arr As Variant Arr = Array(Array(), Array()) End Sub 回答1: This is

Run Time Error 5 when initializing a 2D array

空扰寡人 提交于 2020-01-05 09:27:08
问题 I have been initializing a 2D array using Arr=Array(Array(),Array()) . But I have found that a Run Time Error 5 - Invalid Procedure Call or Argument would be triggered. The code have been used for years and the problem arose yesterday so I think it may be the result of some of the updates for MS Office or Windows. Update: The Error exists for Windows 10, Windows 7 but NOT for Windows Vista. To reproduce the Error: Sub foo() Dim Arr As Variant Arr = Array(Array(), Array()) End Sub 回答1: This is

Access Multi-field Search with Results as you type

风流意气都作罢 提交于 2020-01-05 09:02:22
问题 Good morning, all, My question today is regarding multi-field search. I have a split form (fields and individual record at the top, all data in datasheet view on the bottom). I have multiple fields I would like to search on, so that a user may find a particular person based on a number of criteria. Here is the VBA that a colleague helped me with that works PERFECTLY right now, and I'd like to add just a bit more functionality to it by allowing it to search on more than just the one field.

Access Input Form with Custom Error Messages

淺唱寂寞╮ 提交于 2020-01-05 08:13:42
问题 The Solution The solution was to not try and capture the errors but do the error handling myself as part of the Add New Record command button: Private Sub buttonNewRecord_Click() Dim ErrorInt As Integer Dim TeleCheck As Variant Name.SetFocus If Name.Text = "" Then MsgBox "Name is missing!" ErrorInt = ErrorInt + 1 End If TeleCheck = DLookup("[Telephone]", "tblColdCallLog", "[Telephone] = '" & Me.Telephone & "'") If Not IsNull(TeleCheck) Then MsgBox "Telephone number already exists in the table