Free Lessons
Courses
Seminars
TechHelp
Fast Tips
Templates
Topic Index
Forum
ABCD
 
Home   Courses   TechHelp   Help   Contact   Merch   Join   Order   Logon   Forums   
 
Back to Access Forum    Comments List
Upload Images | @Reply | Bookmark | Link | Email | Next Unseen |
passing arguments to subform
susan 

17 years ago
This should be an easy one, but I haven’t been able to figure it out.

I have a DB that has a register table and a memo table.  There should only be one record in the memo table for each field in the register table.

I would like to have a sub form (Memo) pop-up from a main form (Register) using a command button.  I have been able to use the following code to open the pop-up form and populate the ID field to match the main form.  

Private Sub Command142_Click()

   DoCmd.OpenForm "frm_memo", , , , acFormAdd, acWindowNormal, Me.ID

End Sub

The following code is in the sub-form on load property:

Private Sub Form_Load()

   If Not IsNull(Me.OpenArgs) Then Me.ID = Me.OpenArgs
   
End Sub

The problem I’m having is that I only want to add the ID if there isn’t a record for this ID already; I don’t want duplicate entries.  I want to search for the ID and pull the matching record and populate the ID field ONLY when no matching fields are found.

Any help would be appreciated.

Thanks
Susan



Answer from Richard Rost:

There are a couple of methods you could use. The BEST method would be to use a DLOOKUP first to see if that record exists. It would be something like:

X = Nz(DLOOKUP("ID","frm_memo","ID=" & ID))
If X = 0 then
   ' record not found
else
  ' record found
end if

You can use the DLOOKUP function to look up a specific value from a table or query.

Please see the following FREE video tutorial on my web site for step-by-step instructions on how to use DLOOKUP:

http://599cd.com/tips/access/dlookup-function?key=BlFAlEx

This thread is now CLOSED. If you wish to comment, start a NEW discussion in Access Forum.
 

Next Unseen

 
 
What's This?

 

The following is a paid advertisement
Computer Learning Zone is not responsible for any content shown or offers made by these ads.
 

Learn
 
Access - index
Excel - index
Word - index
Windows - index
PowerPoint - index
Photoshop - index
Visual Basic - index
ASP - index
Seminars
More...
Customers
 
Login
My Account
My Courses
Lost Password
Memberships
Student Databases
Change Email
Info
 
Latest News
New Releases
User Forums
Topic Glossary
Tips & Tricks
Search The Site
Code Vault
Collapse Menus
Help
 
Customer Support
Web Site Tour
FAQs
TechHelp
Consulting Services
About
 
Background
Testimonials
Jobs
Affiliate Program
Richard Rost
Free Lessons
Mailing List
PCResale.NET
Order
 
Video Tutorials
Handbooks
Memberships
Learning Connection
Idiot's Guide to Excel
Volume Discounts
Payment Info
Shipping
Terms of Sale
Contact
 
Contact Info
Support Policy
Mailing Address
Phone Number
Fax Number
Course Survey
Email Richard
[email protected]
Blog RSS Feed    YouTube Channel

LinkedIn
Copyright 2026 by Computer Learning Zone, Amicron, and Richard Rost. All Rights Reserved. Current Time: 11/14/2026 7:32:08 AM. PLT: 0s