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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Objects on Access Form

Status
Not open for further replies.

JTBorton

Technical User
Jun 9, 2008
345
DE
I am used to creating and working on user forms in Excel and am trying to create a form in access. In Excel VBA, I always name my objects with a 3-letter prefix so that I can refer to them in code. However in access, it seems to not like this very much and breaks the connection to the data field when I rename it. So the question is, if I am not supposed to rename the text boxes and other controls on an Access form, how do I refer to them in VBA code? Also, how do I program the events for controls on an Access form?

-Joshua
Well, You can try banging your head against the wall, but you just end up with lost-time injuries and damaged equipment. [M. Passman]
 
from my forum the only problem it is limited to 25 names tis is for word excel. in access you can use a query. In this case I getting data from a table Called City """ SELECT City.CityID, City.City FROM City ORDER BY [City]; """
Code example for office applications.
Sub FDocument_close()
Dim db As DAO.Database
Dim rst As DAO.Recordset
Dim strSQL As String
Dim strPath As String
Dim doc As Document
Set doc = ThisDocumentstrSQL = "SELECT LastName FROM Addresses ORDER BY LastName"
strPath = "G:\OMR\MRM\1.Management&Admin\Phone List\Phone Book Database.mdb"
Set db = OpenDatabase(strPath)
Set rst = db.OpenRecordset(strSQL)
Do While Not rst.EOFWith doc.FormFields("wfLastName").DropDown.ListEntries.Add Name:=rst(0)
End Withrst.Move
NextLoopSet db = NothingSet
rst = Nothing
End Sub

Never give up never give in.

There are no short cuts to anything worth doing :)
 
Generally in Access we just set the Record Source of our forms to an updateable table and query. Then we set the Control Sources of text boxes, combo boxes, etc to fields from the Record Source. There is no code necessary to update records with values entered into the controls.

If this doesn't answer you question, can you tell us more what you are attempting to do? Also, provide your code.

Renaming controls should not break connections to the Record Source. There are times when the horrible name autocorrect options mess things up.

Duane
Hook'D on Access
MS Access MVP
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top