defaultValue issue

  • Thread starter Thread starter rexHowell
  • Start date Start date
R

rexHowell

I'm a newbie looking for a little bit of help.

I have a form that has a jobsite information and billing
information. I have a button that creates a new record with the same
billing information, for new jobsites.

I can set the defaultValues for the new record button using :

Const Email = """"
Me!Email.DefaultValue = & Me!Email.Value & Email

now once the user changes record numbers, I need the default values to
return to null .. and for some reason I can not get this to happen.

thanks for your time,
rex
 
rexHowell said:
I'm a newbie looking for a little bit of help.

I have a form that has a jobsite information and billing
information. I have a button that creates a new record with the same
billing information, for new jobsites.

I can set the defaultValues for the new record button using :

Const Email = """"
Me!Email.DefaultValue = & Me!Email.Value & Email

now once the user changes record numbers, I need the default values to
return to null .. and for some reason I can not get this to happen.

thanks for your time,
rex[/QUOTE]

You don't show the code you're trying or say in what event you're
running it. FWIW, the DefaultValue property can't be set to Null, as
it's a string property. So you'd have to write

Me!Email.DefaultValue = ""

in the appropriate event.
 
what event in that situation would you use to set the default to null.
I guess my problem is not finding the correct event. Because the
user may choose not to enter a new record with that billing info, so if
the user navigates the record set back to valid records, and comes back
to a new record, I want the default values to be null.

I hope that explains my problem better.

thank you for responding.

Rex
 
rexHowell said:
what event in that situation would you use to set the default to null.
I guess my problem is not finding the correct event. Because the
user may choose not to enter a new record with that billing info, so
if
the user navigates the record set back to valid records, and comes
back
to a new record, I want the default values to be null.

I hope that explains my problem better.

It's a bit complicated to "rescind" the default values, given the way I
think you're approaching it. Let me double-check what you're doing:
you have a button on the form to create a new jobsite record, copying
the billing information from the current record. I guess this is
implemented by setting the DefaultValue property for the controls
containing the billing information, and then going to a new record. Is
that right?

Assuming it is, the problem is that, if the user then moves around in
the form or goes to a different record, you want to clear those default
values. You may also want to clear them when the user saves the new
record; I don't know. Clearing them when the user saves the record is
easy, because you can use the AfterUpdate event for that. But clearing
them just because the user has moved to a different record may be a bit
trickier, because the only event that fires is the Current event, and
that also fires when the user moves to a new record; yet you need to
distinguish the two.

How about this logic: clear the default values in the Current event,
but only if the record that has become current is not the new record?
You might do that with code like this:

Private Sub Form_Current()

If Not Me.NewRecord Then

' Clear default values from billing controls

Me!Email.DefaultValue = ""
Me!SomeOtherControl.DefaultValue = ""
' ... and so on ...

End

End Sub

Does that work for you?
 
Mr. Goldgar,

thank you for all your help, the code I eneded up using was in the
Form_Current event ... like you said. The code I used looked like :

Private Sub Form_Current()

If IsNull(Me![CustomerID]) Then
DoCmd.GoToControl "JobPostalCode"
End If

If Not Me.NewRecord Then
Me!CompanyName.DefaultValue = ""
etc .. etc ..
End if

End Sub

thanks again ... I had been hitting my head against the desk, until
visiting this site and you responding to my post. My head fills better
now.

my next thing to tackle is figuring out how to change a filter or query
from inside of a form. I have a field called OrderStatus which holds
the values OPEN, DISPATCHED, CANCELED, CLOSED, HOLD ...

I want to have buttons in my form that change the querry
<OrderStaus> criteria. ie <Button1><On CLick> <OrderStaus> criteria =
"OPEN"

and then me.refresh the form to represent the changes.

Rex
 
rexHowell said:
Mr. Goldgar,

thank you for all your help, the code I eneded up using was in the
Form_Current event ... like you said. The code I used looked like :

Private Sub Form_Current()

If IsNull(Me![CustomerID]) Then
DoCmd.GoToControl "JobPostalCode"
End If

If Not Me.NewRecord Then
Me!CompanyName.DefaultValue = ""
etc .. etc ..
End if

End Sub

thanks again ... I had been hitting my head against the desk, until
visiting this site and you responding to my post. My head fills better
now.

my next thing to tackle is figuring out how to change a filter or
query from inside of a form. I have a field called OrderStatus which
holds
the values OPEN, DISPATCHED, CANCELED, CLOSED, HOLD ...

I want to have buttons in my form that change the querry
<OrderStaus> criteria. ie <Button1><On CLick> <OrderStaus> criteria =
"OPEN"

and then me.refresh the form to represent the changes.

You're welcome; I'm glad I could help.

To answer your new question, I'd need a bit more information. Since
it's a completely new question, I suggest you post it as the start of a
new discussion thread, rather than as a followup to this one. In that
post, please explain whether it's the current form's filter or
recordsource you want to change, or whether it's some other form or even
a stored query. Assuming you want to change what is displayed on the
current form -- that is, the form containing the buttons -- it would
help if you stated the form's recordsource. If it's a stored query,
please give the SQL of the query.

I'll keep an eye out for your message, but someone else may give you a
good answer even before I see it.
 
Back
Top