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

SetValue

Status
Not open for further replies.

JSD

Technical User
Jan 18, 2002
189
US
Hello,

I am trying to use SetValue in a macro. Whaqt I'm trying to do is set the value of a control on a subform = 1.

Item: [Forms]![frmwipin_plantone2]![Text89]
Expression: 1

Not sure where I'm going wrong. Any suggestions are extremely appreciated.

Thanks

Jeremy
 
You dont actually tell us whats happening (eg. error messages), so its a little hard to second guess you. Anyway, check the following:

(a) Does the Text89 control exist on an OPEN form called frmwipin_plantone2 at the time the macro is called. ie. the form must be open and the names have to be consistent.

(b) How are you triggering the macro; I presume via a button on the open form, in which case it should work ok.

(c) try learning a little VBA programming, and avoid macros; they are messy, unstructured little gremlins. Read up a little on events; eg. how you can control what happens on a form when you click a button, and so on.

Hope this helps,


Steve Lewy
Solutions Developer
steve@lewycomputing.com.au
(dont cut corners or you'll go round in circles)
 
Steve101 ,

True, I don't know much about VB. However, I do prefer to use VB, but in this case I'm trying to trigger VB commands in an Autokeys macro. I wouldn't have posted this if I didn't need to assign an f-key for every button on my form because for this database on the shop floor, users will get the mouse all oily.

That said, I'm trying to set the value of the control Text89 = to '1' after I hit an f-key assigned to a macro that does so. I was using this:

[Forms]![frmwipin_plantone2]![Text89]

but I'm not sure that will work because Text89 is on a subform called 'frmwipin_plantone'. 'frmwipin_plantone2' is the main form. I tried using both names, and even 'Child1' which is what the subforms reference name is. I could probably do something like Me!Text89.Value = 1 OnClick of a button on the subform, but like I saud I need this to work in a macro so I can trigger it with an f-key. Hope this clarifies. Sorry I don't have an error message, it's late and I just got booted off the network. Please help a desperate understudy.

Thanks

Jeremy


 
OK. You've supplied some additional relevant info (ie. the bit about the subform). Try the following syntax for the macro's item parameter:

Forms!frmwipin_plantone2!frmwipin_plantone.Form!Text89

That should hopefully work - the syntax for referencing subform items is a little tricky.

Hope this does it,


Steve Lewy
Solutions Developer
steve@lewycomputing.com.au
(dont cut corners or you'll go round in circles)
 
Hello again,

Thanks for your time and expertise. I hace tried what you suggested. Now I get the error 'the object you have referenced in the Visual Basic Procedure as an OLE object isn/t an OLE object.' What does this mean? Is there a way around this?

Thanks,

Jeremy
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top