Hi All,
Very new to Access VBA environment. Was looking for some help.
Issue: Form won't display and Access Freezes
VBA Methodology Being Implemented: I'm using the collections.controltype to auto-bound fields and to pull record information. The forms don't have a lot of fields. Prior to this, I was calling each textbox and using dlookup to get the record information, and never had a problem. The overall code is very simple, I'm just passing the primary key through the main module. I'm also not .repainting or doing any other type of "screenupdating = FALSE" stuff.
What I've Noticed: A) It works intermittently. B) I used the immediate window and saw that the code is executing and ending. What I can't find is why the form does not show up. C) I even put a closeform command at the end of the sub, and that fires off and Access doesn't freeze. I did this because I thought that Access might be stuck in a loop.
*I am aware that there are other VBA techniques that I can use. But, for now I'm comfortable with this way; so I want to figure out what's happening within the scope of using the collections.controltype object reference.
Below is a sample of the code:
Code:
strAr() = Split(Me.Name, "_", -1, vbTextCompare)
aString = strAr(LBound(strAr))
For Each ctL In Me.Controls
With ctL
If .ControlType = acTextBox Then
.Enabled = True
If Not (.Name = "FieldNameA") Then
dString = DLookup("[" & ctL.Name & "]", aString, "[PrimaryKey] = " & PrimaryKey)
ctL = dString
Else
End If
End If
End With
Next ctL
Can anyone provide any guidance?
Thanks!
FrmVBAJunkie