Results 1 to 6 of 6
  1. #1
    d9pierce1 is offline Expert
    Windows 10 Access 2016
    Join Date
    Jan 2012
    Location
    Oklahoma
    Posts
    776

    Default Value of field on form?

    Test Business.zipHI all,
    I have a txt box on a subform called DBA,
    Form is frmBusiness
    SubForm is sfrmBusiness
    Source Object is sfrmEntity

    I am trying to set the default value of this textbox TxtDBA to, if null then nothing, if not null, then what ever is in the textbox DBA formatted to D.B.A.: Whatever is in txtbox DBA



    I have tried the following to no avail....
    Code:
    Iff IsNull([DBA])," ", D.B.A. & [DBA]
    
    
    Iff IsNull([DBA])," ", "D.B.A." & [DBA]
    
    
    IIf(IsNull([Forms]![sfrmEntity]![DBA])," "," DBA:" & ([Forms]![sfrmEntity]![DBA])
    
    
    IIf(IsNull([Forms]![sfrmBusiness]![DBA])," "," DBA:" & ([Forms]![sfrmBusiness]![DBA]))
    
    
    IIf(IsNull([Forms]![frmBusiness]![Form]![sfrmBusiness].[DBA])," "," DBA:" & ([Forms]![frmBusiness]![Form]![sfrmBusiness].[DBA]))
    Any ideas?
    I could maybe put something in the Qry also? Not real sure on that

    Thanks
    Dave
    Last edited by d9pierce1; 08-30-2022 at 08:47 AM. Reason: add db and comments

  2. #2
    xps35's Avatar
    xps35 is offline Competent Performer
    Windows 10 Office 365
    Join Date
    Jun 2022
    Location
    Schiedam, NL
    Posts
    232
    I looks like you want to add a label to the value of a field. That is no good idea. Use labels as labels and keep field values "clean".

    If you still want to do this, I think you have to create an update query to adjust existing (not null) values. For new records set the default value property of the table field to "D.B.A.:".

  3. #3
    d9pierce1 is offline Expert
    Windows 10 Access 2016
    Join Date
    Jan 2012
    Location
    Oklahoma
    Posts
    776
    Its not a label, there are two txt boxes, one TxtDBA and one DBA... I want to take the value of DBA and put that value in
    TxtDBA. and if nothing in DBA then TXTDBA would be blank
    Thanks

  4. #4
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows 10 Access 2016
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,544
    I don't understand the requirement. Both textboxes are using the same Control Source (DBA) so if you change the value in either, the other will change as well.
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  5. #5
    d9pierce1 is offline Expert
    Windows 10 Access 2016
    Join Date
    Jan 2012
    Location
    Oklahoma
    Posts
    776
    I got it fixed, I put the following in the query and it works as expected.
    Thanks everyone
    Code:
    DBAName: IIf(IsNull([DBA]),"","DBA: " & [DBA])

  6. #6
    d9pierce1 is offline Expert
    Windows 10 Access 2016
    Join Date
    Jan 2012
    Location
    Oklahoma
    Posts
    776
    Hi Bob,
    Hope you are well!
    I was using this as my population for the address so when a company is DBA, then it will state that in my Address Box as a DBA: Some Company
    Its all good! just needed to put it in a query rather then a default.
    Thanks
    Dave

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

Similar Threads

  1. Default Value of a field in the form
    By AMJADJ in forum Forms
    Replies: 5
    Last Post: 07-13-2018, 02:38 AM
  2. Set Default field in a form
    By rebfein in forum Forms
    Replies: 3
    Last Post: 09-13-2016, 11:37 AM
  3. Form in which each field is a default value.
    By Abacus1234 in forum Forms
    Replies: 3
    Last Post: 12-12-2015, 01:51 PM
  4. Replies: 6
    Last Post: 10-20-2012, 04:45 PM
  5. Set the default field for form veiw
    By amer in forum Database Design
    Replies: 2
    Last Post: 06-16-2010, 11:32 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