Results 1 to 7 of 7
  1. #1
    markjkubicki's Avatar
    markjkubicki is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Jul 2010
    Location
    Fire Island Pines, NY
    Posts
    496

    assigning the inital value to an option frame control

    on the form is an option frame
    based on the status of other controls on the form, I want to adjust the current option within the frame so that the user can skip a step of having to select the option (unless they specifically want to use a different one than would be usual...)

    ex:
    HTML Code:
    if me.txt1 = "blah" and me.txt2 = "blah blah" then
         me.frmFrame = 2
    else
         me.frmFrame = 3
    end if
    with thanks in advance,
    mark

  2. #2
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,442
    if txt1 and txt2 are combo boxes you should be using the bound column to validate (i.e. if your combo boxes are using the primary key of the 'lookup' table) your data and not enclosing the value in quotes (unless you're building your own primary key)

    I can't imagine txt1 and txt2 are free form text fields if you are trying to default a third option to what is actually typed in.

    If txt1 and txt2 are combo boxes but the values are, in fact text, your code should work fine you would just have to put it in the proper event code for both txt1 and txt2 i.e.

    Code:
    Function CheckFrame()
    if txt1 = "TEST STRING1" and txt2 = "TEST STRING2" Then
        frmFrame = 2
    else
        frmFrame = 3
    End If
    End Function
    Then in the 'after update' or 'on exit' property of both txt1 and txt2 you'd have the code

    Code:
    checkframe

  3. #3
    markjkubicki's Avatar
    markjkubicki is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Jul 2010
    Location
    Fire Island Pines, NY
    Posts
    496
    well... what I'm actually doing is saving the option that the user last used in a table and wanting to restore the frame to that option the next time the user opens that field (so, the example I provide is actually not the case at all ...I just thought it would be easier to explain... (sorry for the confusion; I was thinking it was going to be an easy answer)

    the value is stored in a field in the table tbeFixtureSchedulePrintOptions
    and in the form's OnOpen event, I have code that looks up the value and assigns it to the frame

    the actual code is:
    me.frmPrintOptionFormat = DLookup("[PrintOptionFormat]", "tbeFixtureSchedulePrintOptions")

  4. #4
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,442
    Is the dlookup giving you the expected value? (use debug.print DLookup("[PrintOptionFormat]", "tbeFixtureSchedulePrintOptions") to see if it is)

    If the lookup is giving you the correct value you will likely have to program for the value being missing

    so assuming you have a front end for each person and there is either 1 or 0 records in the table tbeFixtureSchedulePrintOptions you would have

    Code:
    if dcount("*", "tbeFixtureSchedulePrintOptions") > 0 Then
        frmPrintOptionFormat = dlookup("[PrintOptionFormat]", "tbeFixtureSchedulePrintOptions")
    else
        frmPrintOptionFormat = 'put in whatever your 'default' value is here
    endif
    you may also have to do a conversion on the dlookup, sometimes dlookup will make a number behave like a string but I would check to see if your dlookup is actually giving you the value you expect first, if it's not you have other things going on.

  5. #5
    Micron is offline Virtually Inert Person
    Windows 7 32bit Access 2007
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,803
    I think your problem is that you've bound the frame to a recordsource (table or query). You cannot update it as you wish. Unbind it and store the last selected value in a variable, either in as Public in a standard module, or within the procedure, or in the declarations section at the top of your form module. These all have different scopes, so you have to choose the least wide scope that will work.
    Last edited by Micron; 08-12-2015 at 09:44 AM.

  6. #6
    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

  7. #7
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,442
    Oh that's a good catch micron, I hadn't even considered the option group might be bound.

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

Similar Threads

  1. Adding option within a frame
    By crowegreg in forum Forms
    Replies: 1
    Last Post: 09-11-2012, 01:51 PM
  2. Subform control via main form (or better option)
    By dwnocturnal in forum Forms
    Replies: 14
    Last Post: 11-05-2011, 11:24 AM
  3. Replies: 5
    Last Post: 06-10-2011, 03:31 PM
  4. Replies: 8
    Last Post: 05-26-2011, 07:44 AM
  5. Replies: 0
    Last Post: 04-22-2011, 04:58 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