Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Hidden form Control?

Status
Not open for further replies.

hoialmen

MIS
Dec 10, 2001
53
US
Hi All!

I feel like a real dope for asking this question as I have been working as an Access programmer for nearly 6 years, but...

Does anybody know if it is possible to update a field in a form's Record Source (through the form) without having a control on the form that is associated with that field?

Here's my dilemma: I am making some updates to an Access app that was developed by someone who is long gone now and was kind enough NOT to leave any documentation behind. Within the app, there is a form that is used by users to make updates to some of the database records. In the form's Record Source, there are 2 fields, last_updated_date and last_updated_by that capture these values whenever a record is updated. Now, the problem I'm having is in the VBA behind this form there is a Sub routine that looks like:


Private Sub Form_BeforeUpdate(Cancel As Integer)

On Error GoTo Err_Process

If txtItem = "" Or IsNull(txtItem) Then
Me.Undo
Cancel = True
Else
Me.last_update_date = Now()
Me.last_updated_by = strUserName

End If

Exit_Process:
Exit Sub
Err_Process:
MsgBox Err.Description
Resume Exit_Process:
End Sub



OK, so far everything looks pretty standard, however, the form controls Me.last_update_date and Me.last_updated_by don't seem to exist on the form. Another thing that I found interesting is that the only property these controls have available is "Value", So, I'm wondering, is there a way to somehow insert a Record Source field directly into a form without actually assigning it to a control? Seems simple but I'm stumped. Any thoughts will be greatly appreciated.


Thanks in advance!

Nate
 
Hi Nate,

I'm not entirely sure what you are asking, but what you're actually looking at here are Properties of the Form, not Controls. A property is created for each control AND each field in the record source with a name which does not match any control.

For example, if you have a Record Source with a Field called Field1 and it is bound to a Control called Text1 then there will be two Properties of the Form - Field1 and Text1. I wouldn't recommend this, but if you also had another Field in the Record Source called Text1 it would not be available through the form because the Property would refer to the Control (bound to Field1) rather than the Field (not bound to anything).

Controls have all sorts of properties; fields only the one.

Enjoy,
Tony
 
Tony,

Thanks for clarifying! In 6 years of programming Access apps, I have never used this approach to update fields in a form's recordset. I guess I have never needed to update a field that wasn't being displayed on the form or, if I did (for example updating an Edited_By or Edited_Date field), I just executed a SQL statement to accomplish this.

Thanks again and happy programming!

Nate

Nathan C. Hoialmen
President
Encephalon Business Solutions, LLC
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top