Free Lessons
Courses
Seminars
TechHelp
Fast Tips
Templates
Topic Index
Forum
ABCD
 
Home   Courses   TechHelp   Forums   Help   Contact   Merch   Join   Order   Logon  
 
Back to Access Forum    Comments List
Upload Images   @Reply   Bookmark    Link   Email   Next Unseen 
Partial Solution
David McAfee 
    
3 years ago
I've managed to get this to work using a subform with the following code:

    
DetailsIf SpanType.Value = ("Arch") Then
        [ShowandTellSub].[Selection] = ("Arch")
    End If

    If SpanType.Value = ("Beam") Then
        [ShowandTellSub].[Selection] = ("Beam")
    End If
    
    If SpanType.Value = ("Cable-Style") Then
        [ShowandTellSub].[Selection] = ("Cable-Style")
    End If
    
    If SpanType.Value = ("Suspension") Then
        [ShowandTellSub].[Selection] = ("Suspnsion")
    End If
    
    If SpanType.Value = ("Truss") Then
        [ShowandTellSub].[Selection] = ("Truss")
    End If
    If SpanType.Value = ("Other (Specify)") Then
        [ShowandTellSub].[Selection] = ("Other (Specify)")
    End If


The only problem is I get an Run Time error message 2465 Can't find the field '[1'. When I click on End, the image and text show up as they are supposed to. See the follow image.
David McAfee OP  @Reply  
    
3 years ago

Kevin Robertson  @Reply  
          
3 years ago
When you click debug in the error message box which line is highlighted?

Does the Combo Box have an ID as the bound column? You may have to access the Combo Box's Column property.

Also consider using Else If instead of individual If blocks. Each of them will have to be evaluated even if the item is found in the first block.

Example:
    If SpanType.Column(1) = "Arch" Then
        ShowandTellSub!Selection = "Arch"
    ElseIf SpanType.Column(1) = "Beam" Then
        ShowandTellSub!Selection = "Beam"
    End If
David McAfee OP  @Reply  
    
3 years ago
Thanks Kevin. The SpanType field does not have it's own ID. I could have set it up that way but I didn't because it is one of many fields in my form and the bridges main form is one of fourteen mains (roads, parks, buildings, culverts, etc).

I did try the else if and may go back to that.

When debugging, the line that is highlighted is the one I have selected in the combo box.

Also, I'm using the "on click" property and I wonder if I should try something else?

David McAfee OP  @Reply  
    
3 years ago
Problem solved! I'm not sure why, but I decided to delete the form control "SpanType" and redo it. Viola! No error message. Thank you are for trying to help me through this!
Kevin Yip  @Reply  
     
3 years ago
The "field '[1'" error usually indicates an unqualified name somewhere.  It is admittedly a confusing-looking error message, one of many quirks in Access.

If your code is in the main form, and you want to reference the subform "ShowandTellSub", your code should be:

     [ShowandTellSub].Form.[Selection] = ("Arch")

because the name "ShowandTellSub" is just a subform *control*; you need its "Form" property to reference the actual subform itself.

If your code is in the subform, it should be:

     Me.[Selection] = ("Arch")

You cannot just use the subform name "ShowandTellSub" to subtitute "Me" here.  Using the name "ShowandTellSub" means you have to fully qualify it:

     Forms!MainForm![ShowandTellSub].Form.[Selection] = ("Arch")

In short, the code [Subform Name].[Field Name] is wrong no matter where you use it.

P.S.:

You can shorten your entire code to just:

     [ShowandTellSub].Form.[Selection] = SpanType

No need to use If...Then to check for validity of the individual values.  The valid values are already specified inside the combo box.

No need to use .Value for the combo box, in most cases.  The rare case to use it is when you are typing inside and changing the combo box's content, in which case .Value is the original value before the change, and .Text is the value you are seeing as you are typing.

Also, no need to enclose strings with parentheses.  Just write "Arches" instead of ("Arches").

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

Next Unseen

 
New Feature: Comment Live View
 
 

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: 5/6/2026 9:18:57 PM. PLT: 1s