2 Replies - 281 Views - Last Post: 04 January 2019 - 09:23 PM

#1 prkundan   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 24
  • Joined: 14-June 18

New rec through code

Posted 03 January 2019 - 10:56 PM

Private Sub MoveToMain()
Me.Parent.FNAME = NAME
Me.Parent.LNAME = LNAME
Me.Parent.ADD = ADD
Me.Parent.[ADD 1] = [ADD 1]
Me.Parent.[ADD 2] = [ADD 2]
Me.Parent.PLACE = PLACE
Me.Parent.PIN = PIN
Me.Parent.DISTRICT = DISTRICT
Me.Parent.STATE = STATE
End Sub
:code:

I have written the above code to transfer fields from subform to main form. This transfer takes place when I click a field on the subform. But I want to ensure that the transfer is to a new record on the main form. It should not overwrite old records on the main form. How to achieve it?

This post has been edited by modi123_1: 03 January 2019 - 11:08 PM
Reason for edit:: In the future please use the [code] tag button in the editor


Is This A Good Question/Topic? 0
  • +

Replies To: New rec through code

#2 andrewsw   User is offline

  • never lube your breaks
  • member icon

Reputation: 6795
  • View blog
  • Posts: 28,082
  • Joined: 12-December 12

Re: New rec through code

Posted 04 January 2019 - 01:33 AM

You would first need to store the values in variables, then tell the main form to go to the new record. There is a DoCmd action to move to the new record. You need to store the values because, as soon as you move to the new record, the subform will also 'move'.

But why would your main form contain the same data as its subform. (The subform information should be subordinate to the main form's.)
Was This Post Helpful? 0
  • +
  • -

#3 prkundan   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 24
  • Joined: 14-June 18

Re: New rec through code

Posted 04 January 2019 - 09:23 PM

View Postandrewsw, on 04 January 2019 - 01:33 AM, said:

You would first need to store the values in variables, then tell the main form to go to the new record. There is a DoCmd action to move to the new record. You need to store the values because, as soon as you move to the new record, the subform will also 'move'.

But why would your main form contain the same data as its subform. (The subform information should be subordinate to the main form's.)



My main & subform are based on the same table. I am not duplicating data. My subform contains addresses already present. If a new record on the main form requires the same address then I need not type it, I will just click on the subform.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1