Passing values to next record (now all fields are blanked out)

J

jsccorps

When I save the existing record, I want to pass the first field, SalesRep, to
the new record. Currently, all the fields are blanked out in the next
record. It would save my data entry folk some time if the Sales Reps name
would pass on automatically to the next record.
 
J

John Vinson

When I save the existing record, I want to pass the first field, SalesRep, to
the new record. Currently, all the fields are blanked out in the next
record. It would save my data entry folk some time if the Sales Reps name
would pass on automatically to the next record.

You can set the DefaultValue property of the control in its
AfterUpdate event. I'd assume that you're using a Form with a Combo
Box to select the SalesRep from a table of sales reps, and that the
combo is named cboSalesRep (if the situation is different you can
adapt this suggestion or post back): open the form in design view,
view the Properties of cboSalesRep, click the ... by the AfterUpdate
property and select Code Builder. Edit the Sub and End Sub lines
Access gives you to:

Private Sub cboSalesRep_AfterUpdate()
Me!cboSalesRep.DefaultValue = """" & Me!cboSalesRep & """"
End Sub

The four quotes are a quick way to insert a " character into a string.

John W. Vinson[MVP]
 
R

RuralGuy

In the BeforeUpdate event of the Form put the following:

Me.txtSalesRep.DefaultValue = Me.txtSalesRep

When I save the existing record, I want to pass the first field, SalesRep, to
the new record. Currently, all the fields are blanked out in the next
record. It would save my data entry folk some time if the Sales Reps name
would pass on automatically to the next record.

_______________________________________________
hth - RuralGuy (RG for short)
Please post to the NewsGroup so all may benefit.
 
J

jsccorps

Having trouble. May be a format problem?? See code below

Private Sub AgentNo_AfterUpdate()

Me!AgentNo.Locked = True ' this works

' Me!AgentNo.DefaultValue = """454""" ' this
does not work
' Forms![Customer Order].AgentNo.DefaultValue = """454""" ' this does
not work
' Me.AgentNo.DefaultValue = Me.AgentNo ' this does
not work
' Me!AgentNo.DefaultValue = Me!AgentNo ' this
does not work
' Me.AgentNo.DefaultValue = """" & Me.AgentNo & """" ' this does
not work
End Sub
 
R

RuralGuy

Hmmm, that's strange. I'm sure John will jump back in and he's
forgotten more than I know. Meanwhile, here's a suggestion from the
big MS: http://support.microsoft.com/?id=210236


Having trouble. May be a format problem?? See code below

Private Sub AgentNo_AfterUpdate()

Me!AgentNo.Locked = True ' this works

' Me!AgentNo.DefaultValue = """454""" ' this
does not work
' Forms![Customer Order].AgentNo.DefaultValue = """454""" ' this does
not work
' Me.AgentNo.DefaultValue = Me.AgentNo ' this does
not work
' Me!AgentNo.DefaultValue = Me!AgentNo ' this
does not work
' Me.AgentNo.DefaultValue = """" & Me.AgentNo & """" ' this does
not work
End Sub

John Vinson said:
You can set the DefaultValue property of the control in its
AfterUpdate event. I'd assume that you're using a Form with a Combo
Box to select the SalesRep from a table of sales reps, and that the
combo is named cboSalesRep (if the situation is different you can
adapt this suggestion or post back): open the form in design view,
view the Properties of cboSalesRep, click the ... by the AfterUpdate
property and select Code Builder. Edit the Sub and End Sub lines
Access gives you to:

Private Sub cboSalesRep_AfterUpdate()
Me!cboSalesRep.DefaultValue = """" & Me!cboSalesRep & """"
End Sub

The four quotes are a quick way to insert a " character into a string.

John W. Vinson[MVP]

_______________________________________________
hth - RuralGuy (RG for short)
Please post to the NewsGroup so all may benefit.
 
J

jsccorps

ok

I got it to work for text (string) values, using the following format

Me!cboSalesRep.DefaultValue = """" & Me!cboSalesRep & """" ' SalesRep is
text

However, I need it to work for Long (numbers). AgentNo is a Long.

RuralGuy said:
Hmmm, that's strange. I'm sure John will jump back in and he's
forgotten more than I know. Meanwhile, here's a suggestion from the
big MS: http://support.microsoft.com/?id=210236


Having trouble. May be a format problem?? See code below

Private Sub AgentNo_AfterUpdate()

Me!AgentNo.Locked = True ' this works

' Me!AgentNo.DefaultValue = """454""" ' this
does not work
' Forms![Customer Order].AgentNo.DefaultValue = """454""" ' this does
not work
' Me.AgentNo.DefaultValue = Me.AgentNo ' this does
not work
' Me!AgentNo.DefaultValue = Me!AgentNo ' this
does not work
' Me.AgentNo.DefaultValue = """" & Me.AgentNo & """" ' this does
not work
End Sub

John Vinson said:
On Sun, 21 Aug 2005 16:32:02 -0700, "jsccorps"

When I save the existing record, I want to pass the first field, SalesRep, to
the new record. Currently, all the fields are blanked out in the next
record. It would save my data entry folk some time if the Sales Reps name
would pass on automatically to the next record.

You can set the DefaultValue property of the control in its
AfterUpdate event. I'd assume that you're using a Form with a Combo
Box to select the SalesRep from a table of sales reps, and that the
combo is named cboSalesRep (if the situation is different you can
adapt this suggestion or post back): open the form in design view,
view the Properties of cboSalesRep, click the ... by the AfterUpdate
property and select Code Builder. Edit the Sub and End Sub lines
Access gives you to:

Private Sub cboSalesRep_AfterUpdate()
Me!cboSalesRep.DefaultValue = """" & Me!cboSalesRep & """"
End Sub

The four quotes are a quick way to insert a " character into a string.

John W. Vinson[MVP]

_______________________________________________
hth - RuralGuy (RG for short)
Please post to the NewsGroup so all may benefit.
 
J

John Vinson

ok

I got it to work for text (string) values, using the following format

Me!cboSalesRep.DefaultValue = """" & Me!cboSalesRep & """" ' SalesRep is
text

However, I need it to work for Long (numbers). AgentNo is a Long.

The DefaultValue property of a Control is a string property,
regardless of the datatype of the field to which it is bound. Setting
it to "343" with an expression identical to what you have posted here
should work just fine.


John W. Vinson[MVP]
 
Top