Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Text box default value in a continuous form 1

Status
Not open for further replies.

TCARPENTER

Programmer
Mar 11, 2002
766
US
Ok I'm stumped. I have a subfrom displayed as datasheet with three fields I need to populate; Name, Prompt and Type. For this exercise, Name and prompt are going to be identical so I set the DefaultValue property of the txtPrompt text box =[txtNAME]. I get nothing. I tried Roy Vidar's solution from another post and I can get the next record to default to the previous - but I need it in the same record. I tried referencing the txtNAME box by using Forms!mainform!subform!txtName and I get either ?Name, or #Error. What gives?

Thanks for any help or suggestions.
Todd
 
How are ya TCARPENTER . . .

In the [blue]On Current[/blue] event of the subform try this (be sure to disable your other code so there's no interaction):
Code:
[blue]   Dim rst As DAO.Recordset, DQ As String
   
   Set rst = Me.RecordsetClone
   DQ = """"
   
   If Not rst.EOF Then
      rst.MoveLast
      Me!Name.DefaultValue = DQ & rst!Name & DQ
      Me!Prompt.DefaultValue = DQ & rst!Prompt & DQ
   End If
   
   Set rst = Nothing[/blue]

Calvin.gif
See Ya! . . . . . .
 
Thanks AceMan...

I changed:
Code:
  [red]Me!Name[/red].DefaultValue = DQ & rst!Name & DQ
  [red]Me!Prompt[/red].DefaultValue = DQ & rst!Prompt & DQ

To:
Code:
  [red]Me!txtName[/red].DefaultValue = DQ & rst!Name & DQ
  [red]Me!txtPrompt[/red].DefaultValue = DQ & rst!Prompt & DQ
I get the same results as with Roy Vidar's solution - (I think maybe I'm trying to eat my cake and have it too), but I was hoping to be able to enter the data in the txtName and have the txtPrompt text box pick it up.

Now I'm curious though, why doesn't this work in the properties dialog box? It doesn't mention anything about this not working in the help files.
 
And by the way, thanks AceMan, you rock! Have a star!
 
TCARPENTER said:
[blue] . . . I was hoping to be able to enter the data in the txtName and have the txtPrompt text box pick it up.[/blue]
I didn't quite understand it that way . . . in that case in the [blue]AfterUpdate[/blue] event of [blue]txtName[/blue] copy/paste the following (be sure to disable/delete the previous code in the OnCurrent event so there's no interaction):
Code:
[blue]   Me!txtPrompt = Me!txtName
   Me![b][i]NextTextboxName[/i][/b].SetFocus[/blue]
This is simply a copy and has nothing to to with setting the [blue]Default Value[/blue] which has to do with a new record.

With the code above . . . change [blue]txtName[/blue] on any record and [blue]txtPrompt[/blue] follows along . . .

Calvin.gif
See Ya! . . . . . .
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top