Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7697661
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T22:04:04+00:00 2026-05-31T22:04:04+00:00

I have a sub form in Access: The CopyNo is a combobox that lets

  • 0

I have a sub form in Access:
enter image description here
enter image description here

The CopyNo is a combobox that lets me select from the MovieCopies table. When I select one, I want the Title field to show the correct movie title associated to that copy’s movie ID. I also want the format to show. When I select from DaysRented combobox, if I select 1 and the movie is New, I want it to display the price, if it is regular for 3 days display the correct price etc.

I’m just not sure how to give logic to the comboboxes.

If anyone could point me in the right direction of how to do this sort of thing in Access 2007 I’d really appreciate it.

Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T22:04:05+00:00Added an answer on May 31, 2026 at 10:04 pm

    Something like this:

    Private Sub cboCopyNo_AfterUpdate()
        If Nz(Me.cboCopyNo, "") <> "" Then
            Me.txtTitle = DLookup("Title", "MovieMaster", "MovieID = " & Me.cboCopyNo)
        End If
    End Sub
    
    Private Sub cboDaysRented_AfterUpdate()
       If Nz(Me.cboDaysRented, 0) > 0 Then
          Dim strType as String
          strType = DLookup("[Type]", "MovieMaster", "MovieID = " & Me.cboCopyNo)
          If Me.cboDaysRented = 1 Then
              Me.txtPrice = DLookup("Price1Day", "Price", "[Type] = '" & strType & "'")
          Else
              Me.txtPrice = DLookup("Price3Day", "Price", "[Type] = '" & strType & "'")
          End If
       End If
    End Sub
    

    Couple notes. Some of your field names are reserved words in certain databases, such as “Type”. I highly recommend you try to use field names that are not reserved words in Access or SQL server.

    DLookups are not necessarily the fastest way to lookup data but will likely be fast enough for what you’re trying to do here. Sometimes I create my own DAO recordset and lookup the values I want rather than using DLookup. It’s basically like writing your own DLookup function.

    DLookup uses SQL language so your syntax in the third argument, the WHERE clause, needs to match SQL. If the field in your WHERE clause is text/string you’ll need to use a single quote on either side of the value (as shown above around the strType variable). If it is a number field you will not need the quotes. If it’s a date you’ll need hash signs (#).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a form in access with a button that lets user select a
I have an access form that creates a ppt file (set of slides) from
I have a form that can open a sub form (with ShowDialog ). I
I have a form that I want to be used to add entries. Once
I have a very generic login form created that allows a user to access
I have a very simple table in access. The data is stored from VB.NET
I have an Access 2003 form with one subform, set to continuous forms, in
Access 2007: I have one form with 100s of records displayed. I have a
I have created a basic form in access that has a couple of buttons
I have a simple MS Access form that has 3 objects: a text box,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.