Results 1 to 3 of 3
  1. #1
    shabbaranks is offline Competent Performer
    Windows 7 32bit Access 2007
    Join Date
    Oct 2011
    Posts
    162

    Programming Access - is there a quicker\better way?

    Hi all,



    Im just curious as to the best method of referencing Access objects declaring strings and writing code. I have about 15 fields to which I want to add from a main form into a sub form and Im using VBA. Do I have to declare them all as strings\double etc and then reference the field to the string and then write the code to add the form fields to the subform or am I going about it the long way.

    So an example would be:

    Code:
    Dim strName as String, mysql as string
    
    strName = me.formname.fieldname
    mysql = ".....Mysqlcode..."
    Hope this makes sense? Thanks

  2. #2
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,726
    If you have fields in a mainform that should be in a subform, it sounds like a table structure issue.
    Normally you mainform/subform are related in a 1:m set up.

    eg 1 Person can have many Hobbies

    So in the example you have a Peoples table and possibly a Hobbies table and a junction table PersonHasHobbies

    and Person (main Form) and PersonHasHobbies (subform)
    and the forms are linked on PersonId

    You may have a different set up, if so , please describe in detail with some example data.

  3. #3
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,018
    Quote Originally Posted by shabbaranks View Post
    ...I have about 15 fields to which I want to add from a main form into a sub form...

    ...Hope this makes sense?
    Sorry, but as presented, it really makes no sense whatsoever! One of the main points in using a Main Form/Subform configuration is to avoid storing one Field in multiple Table!

    Doing so would violate one of the Cardinal Rules of Relational Databases, the Rule of Normalization! Storing a single bit of data in multiple Tables is only acceptable if the Field is being used as a Primary Key/Foreign Key to link two or more separate Tables/Forms.

    Perhaps we can help you, if you give us a plain-language explanation, of exactly what you're trying to do, here.

    Linq ;0)>
    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

Please reply to this thread with any new information or opinions.

Similar Threads

  1. VBA Programming of P_I Matrix in Access
    By Bretz217 in forum Programming
    Replies: 19
    Last Post: 02-25-2013, 08:20 AM
  2. Programming Check Box in MS Access
    By rossi45 in forum Programming
    Replies: 2
    Last Post: 04-16-2012, 10:49 AM
  3. New to programming in MS access 2007...
    By DarrenReeder in forum Programming
    Replies: 5
    Last Post: 12-05-2010, 01:03 PM
  4. New to Access programming
    By pushpm in forum Programming
    Replies: 1
    Last Post: 02-20-2009, 03:03 PM
  5. Programming Language like Access
    By cwf in forum Programming
    Replies: 2
    Last Post: 05-17-2008, 03:02 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums