INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

Transfer information from subform to 3 different fields in a form

Transfer information from subform to 3 different fields in a form

Transfer information from subform to 3 different fields in a form

(OP)
I have a subform in a form which always displays three records.
what i need to do is when a click on a button to transfer these data to three fields in my form.

subform name: subform1
main form : itemsales
fields to update on main form: text1,text2,text3

(text1 should get first record in the subform, text2 should get the second and text3 should get the third one).

what vba code should i use to do that?
thanks

RE: Transfer information from subform to 3 different fields in a form

Values in a form are typically stored in a table. Use DLookup() or other method to display the values on your main form. If you think you need to store the three values in more than one table then it may require some code to lookup and set the values in the main form.

Duane
Hook'D on Access
MS Access MVP

RE: Transfer information from subform to 3 different fields in a form

Assuming you wanted to move the first three records from a subform to controls on the main form

CODE -->

Private Sub Command28_Click()
  'code on main form
  'subform control called SubFrmControl
  'field is called 'data'
  Dim rs As DAO.Recordset
  Set rs = Me.subFrmControl.Form.RecordsetClone
  rs.MoveFirst
  If rs.recordCount = 3 Then
    Me.Text1 = rs.Fields("data")
    rs.MoveNext
    Me.Text2 = rs.Fields("data")
    rs.MoveNext
    Me.Text3 = rs.Fields("data")
  Else
    MsgBox "There are not three records"
  End If
 End Sub 

What is the big picture on what you are trying to accomplish? There may be a cleaner approach. Does not make much sense to me.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close