Jeff,
I thought solving this problem would fix a larger problem but, as "murphy's
law" goes.....
Anyway i was wondering if you maybe able assist on the larger problem?
I have a subform "frmpayments" within a form "frminvoice" and a command
button opening a report "rptInvoice", the problem is if there is no payment
or record on the "frmpayments" when i click on the command button i get a
Run-Time Error '2427'.
Therefore i thought that if i could have a default value in "frmPayments"
this would allow the user to view/print an invoice, but this is not to be.
It appears there must be a record in the subform "frmPayments" OR i'm hoping
there maybe an alternative.
The Run-Time Error refers to the following when i click on Debug, which of
course works perfectly when there's a record in subfrom "frmPayments".
Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
If Me.Debtor.Value = 2 Then
Me.AccountsName.Visible = False
Me.AccountsAddress.Visible = False
Me.AccountsSuburb.Visible = False
Me.InvoiceOwner.Visible = True
Me.InvoiceAddress.Visible = True
Me.InvoiceSuburb.Visible = True
Else
Me.AccountsName.Visible = True
Me.AccountsAddress.Visible = True
Me.AccountsSuburb.Visible = True
Me.InvoiceOwner.Visible = False
Me.InvoiceAddress.Visible = False
Me.InvoiceSuburb.Visible = False
End If
End Sub
Jeff Boyce said:
Greg
You didn't mention how you tried to incorporate the SQL I provided...
I'll recommend that you look up UNION queries in Access HELP for more
explanation. Given what your current row source is (and, as I mentioned)
assuming that your tblPaymentMethod does NOT have an ID = 0, the following
(after your testing and adjustment) should work:
SELECT 0, "(Select)" FROM tblPaymentMethod
UNION
SELECT [tblPaymentMethod].[PMId], [tblPaymentMethod].[Type] FROM
[tblPaymentMethod] ORDER BY [PMId];
You'd want to set the Default Value of the combo box to 0 to see (Select).
--
Regards
Jeff Boyce
Microsoft Office/Access MVP
Microsoft IT Academy Program Mentor
Greg said:
Jeff,
I tried to incorporate your string with what i have now but with no luck.
This is what is currently in the row source.
SELECT [tblPaymentMethod].[PMId], [tblPaymentMethod].[Type] FROM
[tblPaymentMethod] ORDER BY [Type];
Greg.
:
Greg
We may be sharing that feeling...
Are you saying you want a value to appear in the combo box that
isn't in
the
underlying row source?
If so, one way to do this is to create a new row source that
combines
the
value you want with what it already is showing, something like (untested
aircode, your syntax may vary):
SELECT 0, "(Select)" FROM A-Real-Table
UNION
SELECT YourID, YourField FROM A-Real-Table;
This assumes that your YourID field does NOT already have a value of 0.
--
Regards
Jeff Boyce
<Office/Access MVP>
Jeff,
Ooops! I feel like a total blonde! (except i'm not)
Is there a format to how it should appear in the Default Value property?
I wanted the word ( Select ) as the default value in field name "Type".
The field "Type" is in a subform "Payments" within a form "Invoice".
Regards,
Greg.
:
Greg
And you're not finding the Default Value property for your combo box?
--
Regards
Jeff Boyce
<Office/Access MVP>
Jeff,
I'm using Access 2003.
Greg.
:
Greg
I just opened a form in design mode, clicked on a combo box, and
checked
its
properties. It has a property of "Default Value", like on other
controls.
Which version of Access are you using?
--
Regards
Jeff Boyce
<Office/Access MVP>
Hi Jeff,
I checked the combo box properties but there doesn't seem
to
be a
Default
Value there, i know there is on a normal text field.
I thought there maybe a simple bit of code. I've been playing
around
with
bits and pieces i've found from old posts but no luck.
Greg.
:
Greg
Have you opened the form in design mode, clicked on the combo
box,
and
opened that combo box's properties. I believe you can set a
default
value
there.
--
Regards
Jeff Boyce
<Office/Access MVP>
Hi All,
I've searched old posts with not much luck.
I have a subform "frmPayments" within a form "frmInvoices"
I have a combo box "Type" and need a default value (Select) to
appear
in
the
combo box on open of a new record.
Thanks for any help
Greg.