Wrox Programmer Forums
Access VBA Discuss using VBA for Access programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old February 28th, 2005, 05:04 PM
Authorized User
Join Date: Jan 2005
Posts: 51
Thanks: 0
Thanked 0 Times in 0 Posts
Default Display data in a subform

I have two tables:
tCon: tTrans:
ConID TransID
EnvNo EnvNo
Name Money

Basically its a form(works on tTrans) with a subform(works on tCon) in it and what I need it to do is when I type in a EnvNo, after I lose focus with it I need it to display below, where the subform is the informaiton for that EnvNo account(displays Name and desc). How can I go about display that. Here is what I have but I am not sure how to send the id so that it can be displayed in the subform which is part of my main form.

Private Sub txtEnvNo_LostFocus()
On Error GoTo errhandler
    Dim strConId As String
    If txtEnvNo.Text <> "" Then
        intEnvNo = txtEnvNo.Text
        strConId = DLookup("[ConID]", "tCon", "[EnvNo]=" & intEnvNo)
        MsgBox "Please input a EnvNo"
    End If
Exit Sub
    MsgBox "Record does not exist"
End Sub

Old March 1st, 2005, 04:37 PM
Friend of Wrox
Join Date: Mar 2004
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts

If you click on the main table, and then click autoform, it will create a linked main form and subform.

Then use the combo box wizard to find a record on the form, and look up the proper meaningful field on the main form.

Then add this to the form's On Current Event:

   cboYourLookUpComboBox = TransID

   This will synchronize the look up combo box with the main form's current record.



Similar Threads
Thread Thread Starter Forum Replies Last Post
count data from subform Vince_421 Access 1 May 27th, 2006 11:51 AM
Subform not displaying data hikinfool Access 8 February 24th, 2006 06:11 PM
Subform on many to many data aware Access 14 August 12th, 2005 02:36 AM
How to display a table in a Subform Suomi Access 4 July 1st, 2005 09:09 AM
subform data in report exhibitor Access 4 May 16th, 2005 12:19 PM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.