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

Save record from another form

Status
Not open for further replies.

Harr777

Programmer
Sep 25, 2003
71
US
Greetings,

I am trying to write VBA code that would save the record that is currently in another From. I tried this:

Forms!frmMeterReads.DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
Forms!frmMeterReads.DoCmd.GoToRecord , , acNewRec

But I get an error when I execute this code from a button in another Form.

Any ideas?
 
Hi!

Did you try something like:

[tt]Forms!frmMeterReads.Refresh[/tt]

- or perhaps requery

This might bomb if the form isn't open, here's a faq with a function to paste into a module (not forms or reports module) faq181-320, usage:

[tt]if isloaded("frmMeterReads") then
Forms!frmMeterReads.Refresh
end if[/tt]

AND - crossposting (thread705-798958) is frowned upon. Please also take your time to read faq181-2886.

Roy-Vidar
 
Roy,

The problem is the refesh will not save the record and start a new one in the other form. When I run the code that I posted I get an object error. I don't know why it doesn't work.
 
The refresh should save the record, as per the question. To move to a new record too, this should suffice:

[tt]docmd.gotorecord, acdataform, "frmMeterReads",acnewrec[/tt]

Roy-Vidar
 
Roy,
Thank for you input. One last thing that I'm having a problem with.
In the code of Form A I have this code and it works:

Forms!frmMeterReads.txtValid = "True"

And I have this code and it doesn't work:

Forms!frmMeterReads.MonthlyTotalDig = Me!DigMT

I can't figure it out. One thing is is that txtValid is unbound. I also tried assinging Me!DigMT to a variable first and still the value does not transfer to the second form.

Thanks in advance
 
Roy,

Sorry, x that question out. I figured out what was happening.

Thanks anyway
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top