Smart Defaults

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Peter Barker

    #1

    Smart Defaults

    Can anyone say what is wrong with this please:


    Private Sub Combo18_AfterUp date()
    Dim SQLStmt, R As Recordset
    SQLStmt = "SELECT DISTINCT [Height Pixels] FROM [Pictures]WHERE
    [Pictures].[Height Pixels] IS NOT NULL AND [Width Pixels]= '" & Me![Combo18]
    & "';"
    Me![Height Pixels].RowSource = SQLStmt
    Me![Height Pixels].Requery
    Set R = CurrentDb.OpenR ecordset(SQLStm t)
    If R.RecordCount > 0 Then
    R.MoveLast
    If R.RecordCount = 1 Then
    Me![Height Pixels] = R![Height Pixels]
    End If
    End If
    End Sub

    Control Source for Combo18 is Width Pixels. The idea is a “smart” default
    for Height Pixels field, but I just get “Run-time error 438”

    Thanks

    Peter



  • Larry  Linson

    #2
    Re: Smart Defaults

    Maybe I misunderstand, but wouldn't both HeightPixels and WidthPixels be
    numeric? You are enclosing the value for WidthPixels in quotes as though it
    were a string.

    It also appears that you are never setting the value of HeightPixels if more
    than one record was returned. Try indenting your code as a reminder to
    yourself.

    Since you set its RowSource, I assume that the HeightPixels to which you
    refer is a Combo or List Box. Could it be that it has the same name as the
    Field to which it is bound? A Field, of course, does not have a RowSource.

    All of the above are just observations... not related to the error you
    experienced. In regards to which, so people don't have to go look up the
    description of an error*, it's good to include it. It is also useful to
    indicate on which line of the procedure the error occurred. Remote debugging
    is difficult at best, but without all the information, it is impossible.

    * most, like me, just won't take the time to do so
    unless they find the problem very intriguing

    Larry Linson
    Microsoft Access MVP


    "Peter Barker" <peter@exeter.f lyer.co.uk> wrote in message
    news:vq9sqhqon1 oo42@corp.super news.com...[color=blue]
    > Can anyone say what is wrong with this please:
    >
    >
    > Private Sub Combo18_AfterUp date()
    > Dim SQLStmt, R As Recordset
    > SQLStmt = "SELECT DISTINCT [Height Pixels] FROM [Pictures]WHERE
    > [Pictures].[Height Pixels] IS NOT NULL AND [Width Pixels]= '" &[/color]
    Me![Combo18][color=blue]
    > & "';"
    > Me![Height Pixels].RowSource = SQLStmt
    > Me![Height Pixels].Requery
    > Set R = CurrentDb.OpenR ecordset(SQLStm t)
    > If R.RecordCount > 0 Then
    > R.MoveLast
    > If R.RecordCount = 1 Then
    > Me![Height Pixels] = R![Height Pixels]
    > End If
    > End If
    > End Sub
    >
    > Control Source for Combo18 is Width Pixels. The idea is a "smart"[/color]
    default[color=blue]
    > for Height Pixels field, but I just get "Run-time error 438"
    >
    > Thanks
    >
    > Peter
    >
    >
    >[/color]


    Comment

    Working...