update a subform in a main form with a value entered in another form .... (1 Viewer)

Emma

Registered User.
Local time
Today, 10:21
Joined
May 11, 2000
Messages
37
Hi!

I have a main form (job)with a subform (object-job)for objects related to jobs - objects are selected from a combo which looks to the main object table. On the subform, I have a button which opens the objects form which opens as a dialog box keeping the focus until it is closed, so that any new objects not listed in the subforms combo can be entered. When I close the object form I return to the subform object-job, and using a requery event on the focus of the object combo, I can now select the new object and relate it to the job.

However, I was wondering is there a way that once I have entered my new object and closed this form, that the object number can be inserted into the subform, as a new record, of the job that I am updating?

I have tried several things, mainly trying to hack the code that enables the value from one form to be pasted into the value of another form, but to no success!

Any help would be very much appreciated (and would speed up my data entry!)

Many thanks

Em
 

RpbertS

Registered User.
Local time
Today, 10:21
Joined
Feb 14, 2000
Messages
93
as I understand it you have a field that stores the object number on the object form now when that form is closed you want to send that value to a field on your subform.


well this is how I would do it.
you can put this code in the on close even of the form or in the onClick event of your close button on your form.

code(I chose on close)
---------
Private Sub Form_Close()
Forms!formname!fieldname = fieldwithobject#.value
End Sub

I didnt test it and its early but that code should when the form closes send the value to the field of your choosing.

lemme know if you need more help...time to get some hot coco
 

Emma

Registered User.
Local time
Today, 10:21
Joined
May 11, 2000
Messages
37
I tried the code but nothing happened! I entered it as:

forms!frm_job!sfm_ojbectno!object_no = object_no.value

on the OnClose event of the object for, so that the once the object form closes, the object_no field in the subform on the Job form would be updated.

However, it has since occured to be that when I close the object form, I am not telling Access to go to a new record in the subform - which is where the object number value should be going.

So, I inserted a piece of code to say docmd.gotorecord , , acnewrecord but that didnt work either!

I think the difficulty (apart from my appalling VBA skills ...) is that I go from a main form with a subform, to a dialog form, close the dialog form and expect Access to take me back to a new record on the subform into which I copy the value of the record I have just entered in the dialog form...AHHHh! my head hurts!

Any further help would be greatly recieved!

Yours confused and lost
Em

[This message has been edited by Emma (edited 01-19-2001).]
 

RpbertS

Registered User.
Local time
Today, 10:21
Joined
Feb 14, 2000
Messages
93
right, im a little confused also I dont think it should be difficult..hmm..the only thing I could think of if you could send me a small db showing the problem I could get it to work and send it back..im working from home to day so try

Fdarouian@yahoo.com ill prolly have time to look at it around 2

let me know!
 

Emma

Registered User.
Local time
Today, 10:21
Joined
May 11, 2000
Messages
37
Just incase anyone out there reads this thread, the problem has now been solved, with thanks to RPBertS's help!

Rather than putting this code on the form_close event, I put it on the Object forms AfterUpdate event. When I closed this form (which was a dialog ontop of my Jobs form), the value of the object number was appended into the subform ... magic!!!
 

Users who are viewing this thread

Top Bottom