From: poorboy13 on 11 May 2010 16:10 Hello, I am having an issue where I need to have a field on a form populated by the 'Date' Function by a click on a command button. However I am getting an error message that Access can not find the "Date" field. I'm sure this means I've named some object somewhere in my db "Date" but I can't find it. Is there some way of doing a search or listing all the objects by name so I can find the offending piece and rename it? In case you want to make sure my code is correct.... Private Sub Command10_Click() BODDate.Locked = False BeginTime.Locked = False BODDate = Date BeginTime = Now() BeginTime.Locked = True BODDate.Locked = True Present = -1 End Sub Any help would be appreciated. Thanks, poorboy13
From: KARL DEWEY on 11 May 2010 16:55 The problem is with this --- BODDate = Date I do not do vba but try this --- BODDate = Date() -- Build a little, test a little. "poorboy13" wrote: > Hello, > I am having an issue where I need to have a field on a form populated by the > 'Date' Function by a click on a command button. > However I am getting an error message that Access can not find the "Date" > field. > I'm sure this means I've named some object somewhere in my db "Date" but I > can't find it. > Is there some way of doing a search or listing all the objects by name so I > can find the offending piece and rename it? > > In case you want to make sure my code is correct.... > > Private Sub Command10_Click() > BODDate.Locked = False > BeginTime.Locked = False > BODDate = Date > BeginTime = Now() > BeginTime.Locked = True > BODDate.Locked = True > Present = -1 > End Sub > > Any help would be appreciated. > > Thanks, > poorboy13 > > . >
From: fredg on 11 May 2010 19:02 On Tue, 11 May 2010 13:55:01 -0700, KARL DEWEY wrote: > The problem is with this --- BODDate = Date > > I do not do vba but try this --- BODDate = Date() Karl, In VBA (unlike in Access) there is no need to add the () to the Date function. And if you did, the VBA editor would strip them away. I would suspect that the user has a reference problem. Open any module in Design view (or click Ctrl + G). On the Tools menu, click References. Click to clear the check box for the type library or object library marked as "Missing:." An alternative to removing the reference is to restore the referenced file to the path specified in the References dialog box. If the referenced file is in a new location, clear the "Missing:" reference and create a new reference to the file in its new folder. See Microsoft KnowledgeBase articles: 283115 'ACC2002: References That You Must Set When You Work with Microsoft Access' Or for Access 97: 175484 'References to Set When Working With Microsoft Access' for the correct ones needed, and 160870 'VBA Functions Break in Database with Missing References' for how to reset a missing one. For even more information, see http://www.accessmvp.com/djsteele/AccessReferenceErrors.html -- Fred Please respond only to this newsgroup. I do not reply to personal e-mail
From: Linq Adams via AccessMonster.com on 12 May 2010 08:35 I agree with Fred, this is a fairly common problem and almost always a case of a missing reference, and the VBA Editor will, indeed, strip the trailing parens. -- There's ALWAYS more than one way to skin a cat! Answers/posts based on Access 2000/2003 Message posted via AccessMonster.com http://www.accessmonster.com/Uwe/Forums.aspx/access-formscoding/201005/1
From: BruceM via AccessMonster.com on 12 May 2010 11:43
In addition to what has been suggested, look at the top of the code module. If Option Explicit does not appear below Option Compare Database, add it, then compile the code. If you had to add it, in the VBA editor go to Tools >> Options, click the Editor tab, and check Require Variable Declaration. This is how to go about it in Access 2003. I'm not sure how it would be done in later versions. If you are adding values programatically I don't think there is a need to unlock the controls. Also, I would add the Me. prefix: Me.BODDate = Date When you use the prefix, Access will look for BODDate only in the form's properties (which includes fields and controls). Without the prefix Access needs to resolve whether BODDate is a field, function, constant, variable, property, or whatever. Also, the Me prefix followed by a dot presents you with a pick list, which often saves time, and tends to reduce the possibility of typos. Linq Adams wrote: >I agree with Fred, this is a fairly common problem and almost always a case >of a missing reference, and the VBA Editor will, indeed, strip the trailing >parens. > -- Message posted via AccessMonster.com http://www.accessmonster.com/Uwe/Forums.aspx/access-formscoding/201005/1 |