>> Not necessary if not Option Explicit.
>
> Ah, duly noted :o)
Bob,
Open the form in design view, select the button, desplay the properties
window and select tab Events; place the cursor in the On Click property
cox and click on the little button with the ellipsis symbol that appears
on the right. You will be taken to a VA editor screen, with either two
lines od code like:
Private Sub Command1_Click()
End Sub
where Command1 would actually be the name of your command button, or the
same with some lines of code in between, if you carried through the
command button wizard instead od cancelling out, when you created the
command button. In the latter case, delete all lines of code in between
the two shown above. Then paste the code I gave you in between those two
lines, return to form design, save and you're done.
HTH,
Nikos
> Sorry can you tell me how to put a code behind a button, I am a Newbie,
> Thanks Bob
>
>>>Not necessary if not Option Explicit.
>>
>>Ah, duly noted :o)
Bob - 01 Jul 2005 08:41 GMT
I did that and now I am getting a yellow line on this part of the code
Me.Controls(ctl.Name) = Null
Thanks Bob
> Bob,
>
[quoted text clipped - 24 lines]
>>>
>>>Ah, duly noted :o)
Keith - 01 Jul 2005 09:58 GMT
>I did that and now I am getting a yellow line on this part of the code
> Me.Controls(ctl.Name) = Null
> Thanks Bob
If you have "Option Explicit" at the very top of the code then you need this
as the first line for your button:
Dim ctl as Control
Regards,
Keith.
www.keithwilby.com
Nikos Yannacopoulos - 01 Jul 2005 11:17 GMT
Bob,
Keith's suggestion will fix a possible problem, but this is not the only
possible problem. If it's not fixed pls post back the error message.
Nikos
> Sorry can you tell me how to put a code behind a button, I am a Newbie,
> Thanks Bob
Open your form in design view and double-click your command button. This
should reveal the 'properties' box (if it wasn't already there). Click the
'events' tab and select 'Event Procedure' from the drop-down list for the
'on click' event (click at the right-hand side of the seemingly empty box, a
drop-down arrow will appear).
Once you have selected 'Event Procedure' from the drop-down there should be
a small box with three dots in it - click this and paste the code between
"private sub ..." and "end sub" for your command button name.
To make sure there are no errors in the code you must compile it. Do this
by selecting "compile" from the "debug" menu. If all is well, close the
code window and save your form.
HTH - Keith.
www.keithwilby.com
Bob - 01 Jul 2005 19:14 GMT
Still getting a yellow line through Me.Controls...
Private Sub Command40_Click()
Dim ctl As Control
For Each ctl In Me.Controls
If ctl.ControlType = acTextBox Then
Me.Controls(ctl.Name) = Null
End If
Next
End Sub
Thanks Bob
>> Sorry can you tell me how to put a code behind a button, I am a Newbie,
>> Thanks Bob
[quoted text clipped - 15 lines]
> HTH - Keith.
> www.keithwilby.com
Bob - 01 Jul 2005 21:45 GMT
This was at the very top of the page:
Option Compare Database
Thanks bob
> Still getting a yellow line through Me.Controls...
>
[quoted text clipped - 28 lines]
>> HTH - Keith.
>> www.keithwilby.com
Nikos Yannacopoulos - 04 Jul 2005 08:05 GMT
No apparent reason. What is the exact error message?
Nikos
Keith - 04 Jul 2005 08:26 GMT
> Still getting a yellow line through Me.Controls...
>
[quoted text clipped - 7 lines]
>
> End Sub
Works fine for me. Do you have a library reference to DAO 3.6 set? Check
under References from the Tools menu in a code window.