S
S P Arif Sahari Wibowo
Hi!
Do you know how to put a form's Access-Visual-Basic-code that will force
the form to be inserted, while the user has not type anything in the form,
without changing focus, selection, etc.?
Here is the story.
I have this structure:
Table1 <-one-many-> Table2 <-one-many-> Table3
The forms follow that structure:
Form2 (of Table2) subform of Form1 (of Table1)
Form3 (of Table3) subform of Form2 (of Table2)
Now, the records in Table2, although have their own fields, that fields
not always filled by users, and sometime just act as "holder" for a group
of Table3's records. So in the form, sometime users have nothing to type
in Form2, but want to type into Form3 directly. But since Form2 is not
typed in yet, the record is not created yet, and therefore what they type
in Form3 will just gone (not linked to anything).
So what I tried to do, is but an event handler (of BeforeInsert event) in
Form3, calling another code in Form2 or other place if necessary, get that
form "inserted" (get the record created). However, since this will happen
in the middle of the user typing in Form3, it should happen without
changing focus and selection.
So far the only thing can do the insertion, is by having a code moving
some data into 1 or more fields in Form2, and then call the method Requery
or Refresh from Form2. Unfortunately, this reset the Forms display, with
Requery the focus shifted to the first field in Form2, with the Refresh,
either the typing hairline change into selection of that particular field
(in Form3), or Form3 get reset (focus to first field), and the single
character typed disappear. I don't know why it does one or the other.
I tried using Recordset's Update, and RunCommand acSaveRecord, to no
avail.
Any other suggestion?
I use MS Access 2003, BTW.
Thank you!
Do you know how to put a form's Access-Visual-Basic-code that will force
the form to be inserted, while the user has not type anything in the form,
without changing focus, selection, etc.?
Here is the story.
I have this structure:
Table1 <-one-many-> Table2 <-one-many-> Table3
The forms follow that structure:
Form2 (of Table2) subform of Form1 (of Table1)
Form3 (of Table3) subform of Form2 (of Table2)
Now, the records in Table2, although have their own fields, that fields
not always filled by users, and sometime just act as "holder" for a group
of Table3's records. So in the form, sometime users have nothing to type
in Form2, but want to type into Form3 directly. But since Form2 is not
typed in yet, the record is not created yet, and therefore what they type
in Form3 will just gone (not linked to anything).
So what I tried to do, is but an event handler (of BeforeInsert event) in
Form3, calling another code in Form2 or other place if necessary, get that
form "inserted" (get the record created). However, since this will happen
in the middle of the user typing in Form3, it should happen without
changing focus and selection.
So far the only thing can do the insertion, is by having a code moving
some data into 1 or more fields in Form2, and then call the method Requery
or Refresh from Form2. Unfortunately, this reset the Forms display, with
Requery the focus shifted to the first field in Form2, with the Refresh,
either the typing hairline change into selection of that particular field
(in Form3), or Form3 get reset (focus to first field), and the single
character typed disappear. I don't know why it does one or the other.
I tried using Recordset's Update, and RunCommand acSaveRecord, to no
avail.
Any other suggestion?
I use MS Access 2003, BTW.
Thank you!