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

DoCmd ? 3

Status
Not open for further replies.

kermitforney

Technical User
Mar 15, 2005
374
US
Need a Do Cmd for an After Update, Event Procedure.
This is what I need.
When a user inputs the date into the main form I would like it automatically update the Date field in the SubForm.
How would I do this?

Is there a site where I can learn VBA inculding SYNTAX so I can start doing this on my own?
 
I meant another line after the date update line. Have you have tried stepping through the code by adding a breakpoint and then stepping with F8 to see where the problem is?
 
Run-Time error '438':

Object does not support this property or method.
 
Remou: I meant another line after the date update line. Have you have tried stepping through the code by adding a breakpoint and then stepping with F8 to see where the problem is?

Where do I place the Breakpoint in order to step through the code? I have tried but when I press F8 nothing happens so I assume I am doing it incorectly.
 
Sorry ptpaton?!?!?

me![tblCoilTracking subform].form!Date = Format(me.Date,"mm/dd/yy")

Run-Time error '438':

Object does not support this property or method.
 
Go to your code and click in the grey margin beside the sub name so that a brown dot appears and the line is marked or click on the sub name and press F9. Then run your form normally. When you enter the date, the code window will open up allowing you to step through the code with F8, as each line comes up, it will be highlighted making it easy to track what is happening. Don't forget to get rid of the breakpoint when you are finished checking. However, the fact that you cannot format the date suggests some problem with the control. Can you confirm that this:
[tt]me![tblCoilTracking subform].form!CTDate = Format(me.DRDate,"mm/dd/yy")[/tt]
is what you tried, giving this error "Run-Time error '438':", and that all the names are correct?
 
cRap I found out what the issue was and fixed it. What happened was I had changed the table's column name but I didn't change the text boxes control name. :eek:(

Now it is all changed and the error isn't there anymore but the subform's date field no longer updates?? Any clues?

Here is the code:
(All the names are correct.
DRDate=Date field in main form.
CTDate=Date field I want updated in the subform.

Private Sub Date__AfterUpdate()

Me![tblCoilTracking subform].Form!CTDate = Format(Me.DRDate, "mm/dd/yyyy")


End Sub

 
The problem is here: Private Sub Date__AfterUpdate()
You have changed the name of the control, so this is not the after update event for your control. Put in a new after update event and get rid of this one.
 
Compile Error

Method or Data member not found

Private Sub DRDate__AfterUpdate()

Me![tblCoilTracking subform].Form!CTDate = Format(Me.DRDate, "mm/dd/yyyy")

End Sub
 
All I can say is this suggests there is still a problem with the names. For example, when you type Me. (me dot) does DRDate appear in the intellisense list?
 
Try Me.[tblCoilTracking subform].Form!CTDate

Also, make sure that CTDate and DRDate are the actual field names? If the text boxes and the field names are the same, you can also run into problems. Name the fields one thing, and add txt to the start of the name for the control names. So CTDate would be a field in the table, and txtCTDate is the control on the form.

Once that's done, make your code Me.[tblCoilTracking subform].Form!txtCTDate = Format(Me.txtDrDate,"mm/dd/yyyy")

-Patrick

Nine times out of ten, the simplest solution is the best one.
 
As in DRDate_ (underscore)? Because then that underscore is a part of the name, so you will either have to rename (recommended) or change the code to show the underscore. (I was wondering why it looked as if you had two underscores between Date and AfterUpdate - I should have mentioned it, drat.)
 
I feel like such an @$$hole right now. Once I re-checked the names of the controls I found DRdate was really DRdate:.
:eek:(
Man this whole learning process feels more like punishment. (for both parties, hehe)
Thank you sooo much guys, I appreciate it sooo much.

Stars for all !!!!

Quick question.
When I was doing all the me. and Sub stuff is this VBA or just plain ol VB??
 
Cool, thanks gonna do some research s I am not such an clueless @$$ next time. :eek:)
Thanks again for all of the help.
 
Glad to help Kermit!

-Patrick

Nine times out of ten, the simplest solution is the best one.
 
Hi Kermit!

I'm fairly new to VBA and the programmatic side of Access however I found this site to be very useful in helping me understand the basics (i.e. "SYNTAX"):
Also, this book: Microsoft Access VBA Programming for the Absolute Beginner, Second Edition by Michael Vine, I have found to be very useful especially since I am a beginner =)

But everyone here is right...it's mostly self-taught (I don't think I've talked to one person who said they learned it from a class or anything) and a lot of research.

I wish you all the best!

vhbuia
 
Kermit, you are a trouble maker!

j/k

:)

-Patrick

Nine times out of ten, the simplest solution is the best one.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top