same button code - one works one doesn't

H

harleyken

thanks to the guru's

I have the same "on click" code format in two different forms -

- this one works
Me![Entry_date] = Me![Text63]

- this one doesn't
Me![Text36] = Me![Text71]

This is a short date format (text71 is defaulted to "date()")
Text36 is set to a short date format

what else am I missing?
this works in one form, but not the other - I get a error about the on click
event..
 
H

harleyken

the second code is on a sub form so I tried this without luck -

Forms![service_main]![Service_of_Order_Entry]![Text36] =
Forms![service_main]![Service_of_Order_Entry]![Text71]
 
H

harleyken

the code that doesn't work is on a sub form, so I tried this code without any
luck:
Forms![service_main]![Service_of_Order_Entry]![Text36] =
Forms![service_main]![Service_of_Order_Entry]![Text71]
 
B

bcap

There's only one or two telepaths here, the rest of us need to be told what
the error message says.
 
H

harleyken

The expression On Click you entered as the event property setting produced
the following error: A problem occurred while Microsoft Access was
communicating with the OLE server or ActiveX Control.
*The expression may not result in the name of a macro, the name of a
user-defined function, or [Event Procedure].
*There may have been an error evaluating the function, event, or macro.

the help button displays:

Visual Basic for Applications (VBA) encountered a problem while attempting
to access a property or method. The problem may be one of the following:
A reference is missing.
For help restoring missing references, see the Microsoft Knowledge Base
article 283806.
An Expression is misspelled.
Check all expressions used in event properties for correct spelling.
A user-defined function is declared as a sub or as a private function in a
module.
Expressions can resolve a user-defined function only if the function is
declared as one of the following:
A public function in a module
A public or private function in a code module of the current form or report
Security in Access is set to Medium or High and the Microsoft Jet 4.0 SP8
update is not installed.
A more recent verion of Jet 4.0 must be installed for Access to function
properly when security is set to Medium or High. To obtain the latest version
of Microsoft Jet, go to Windows Update.
 
B

bcap

Please post the code for the *entire* procedure, including the "Private
Sub..." and "End Sub" lines.

In the code window, please go to the Tools menu, and choose "References".
If anything in the list is ticked, but also says "MISSING", please post back
with details of what.
 
H

harleyken

Private Sub Command70_Click()
Me![Text36] = Me![Text71]
End Sub

In the references (in order/none missing):
Visual Basic for Applications
Microsoft Access 11.0 Object Library
OLE Automation
Microsoft DAO 3.6 Object Library
Microsoft ActiveX Data Objects 2.1 Library

ps - thx for taking the time to help
 
G

Gina Whipp

harleyken,

Umm, what is NOT happeneing? Is Me![Text36] = Me![Text71] not working?
What is the data type for both fields? What version of Access? Is one on
the main form and the other on a subform or in a tab control?


--
Gina Whipp

"I feel I have been denied critical, need to know, information!" - Tremors
II

http://www.regina-whipp.com/index_files/TipList.htm
 
H

harleyken

Gina;
both are unbound controls with no format set, although the default for
text71 is Date()

Does it make a difference that on Me![Entry_date] = Me![Text63]
entry_date is bound to a table? where on me![text36 = me![text71 it is not
bound?

ken
 
G

Gina Whipp

harleyken,

If they are both unbound then they are BOTH going to null. The field that
contains the date needs to be bound and then the other field (Text71) can be
unbound. So to recap bind Text36 to Entry_date and then Text71 will equal
Text36. (Also, assuming typo in below message of Text63.)

--
Gina Whipp

"I feel I have been denied critical, need to know, information!" - Tremors
II

http://www.regina-whipp.com/index_files/TipList.htm
 
M

Mike Painter

harleyken said:
Private Sub Command70_Click()
Me![Text36] = Me![Text71]
End Sub

What is Text71 and Text36?
If text boxes is there any chance that their names were changed?
It is rarely a good idea to not use descriptive names.
 
H

harleyken

The only difference between the two is that the code that works is bound to a
table..I will try a different approach..

the original idea was to have a unbound date field that contained a date
(text71) that was hidden, and use it to populate one of two fields depending
on which button was clicked to simplify data entry.. I also tried me.text63
= date for the on click of the button - but that didn't work either..i will
re think my plan!

Thanks for the time and thought to help us all!
 
G

Gina Whipp

harleyken,

Remember, unbound fields contain no data so nothing = nothing. The first
field must be bound to something for the second field to show data. You
cannot have an unbound field contain a date from the table, it MUST be bound
to the date field in the table. Perhaps if you explain with more detail why
you need this to happen this way???

When I want a field to default to today's date then I put that in the
Default Vlue of the field at the table level. But judging by what your
doing that won't work for you???

--
Gina Whipp

"I feel I have been denied critical, need to know, information!" - Tremors
II

http://www.regina-whipp.com/index_files/TipList.htm
 
R

Rob G

If you haven't solved this by now, perhaps you should also set the format of
the textbox to a short date in its property page first. You can initialize
the hidden text box in the subform on open event.

Set the text box to visible so that you know it has today's date showing -
until your testing is complete then set it to hidden.

Rob.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top