I would however, its working for [cboClient] and [cboMasterAccount]. My
conclusion is there's something about [cboBillingMethod] itself as
opposed to the code. All three boxes are essentially the same -
comboBoxes loaded from a Select Query with multiple columns, the first
column being the bound column, with the others hidden via ColumnWidths
set to 0. I tried completely deleting the comboBox and placed a new text
box created from directly from the TOOLBOX and in that instance when I
went to a new record, the default value displayed was the ever popular
#NAME? error. Again when I checked the immediate window, the
..defaultValue was as expected. I even tried completely changing the name
of the control (and the appropriate code) and still got the #NAME? error
on a new record. I even tried setting the default value to 'CA' or 'MA'
to ensure that I wasn't using some sort of reserved word. No luck.
David H
John Nurick wrote:
> Have you experimented with the form's Repaint and Refresh methods, or
> perhaps with requerying the comboboxes?
>
> On Sun, 20 Feb 2005 00:26:10 -0500, "David C. Holley"
> <(E-Mail Removed)> wrote:
>
>
>>I'm trying to change the default value of a comboBox via code. The
>>problem that I'm having is that the default value is not being displayed
>>in the combobox [cboBillingMethod] nor is it being stored in the record.
>>I have confirmed that the code is functioning properly in that the
>>default values for [cboClient] and [cboMasterAccount] are being set AND
>>are being used when a new record is added. When I checked the default
>>value of [cboBillingMethod] via the immediate window, it is being set -
>>its just not being used.
>>
>>So what am I missing?
>>
>>David H
>>
>>DoCmd.OpenForm "frmReservations", acNormal, , , acFormAdd
>>Select Case [Forms]![frmInvoicing]![txtAccountType]
>>Case "client"
>>[Forms]![frmReservations]![cboBillingMethod].DefaultValue = "client"
>>[Forms]![frmReservations]![cboBillingMethod].Value = "client"
>>[Forms]![frmReservations]![cboClient].DefaultValue =
>>[Forms]![frmInvoicing]![lngClientID]
>>[Forms]![frmReservations]![cboClient].Value =
>>[Forms]![frmInvoicing]![lngClientID]
>>Case "master account"
>>[Forms]![frmReservations]![cboBillingMethod].DefaultValue = "master"
>>[Forms]![frmReservations]![cboBillingMethod].Value = "master"
>>[Forms]![frmReservations]![cboMasterAccount].DefaultValue =
>>[Forms]![frmInvoicing]![lngMasterAccountID]
>>[Forms]![frmReservations]![cboMasterAccount].Value =
>>[Forms]![frmInvoicing]![lngMasterAccountID]
>>End Select
>
>
> --
> John Nurick [Microsoft Access MVP]
>
> Please respond in the newgroup and not by email.
|