default value

  • Thread starter sobeit via AccessMonster.com
  • Start date
S

sobeit via AccessMonster.com

if me.combo1.value = "record" and me.combo2.value = "record2" then
me.combo2.defaultvalue = "record3
end if

but i get the #Name? error

please help i cannot find the right code
 
L

Linq Adams via AccessMonster.com

I assume the missing closing quotation mark

"record3

is simply a typo.

Where do you have this code placed?
 
J

John W. Vinson

if me.combo1.value = "record" and me.combo2.value = "record2" then
me.combo2.defaultvalue = "record3
end if

but i get the #Name? error

please help i cannot find the right code

We can't see your database, or your form, and it's not at all clear what you
want to accomplish. What are "record" and "record2"? text strings containing
the words "record" and "record2"? What do you want the default value to
become, and why?
 
S

sobeit via AccessMonster.com

if me.combo1.value = "depart1" and me.combo2.value = "task1" then
me.combo2.defaultvalue = "task2"

both combo has limit to list property though the "task2" is still in the list


if me.combo1.value = "record" and me.combo2.value = "record2" then
me.combo2.defaultvalue = "record3
[quoted text clipped - 3 lines]
please help i cannot find the right code

We can't see your database, or your form, and it's not at all clear what you
want to accomplish. What are "record" and "record2"? text strings containing
the words "record" and "record2"? What do you want the default value to
become, and why?
 
J

John W. Vinson

if me.combo1.value = "depart1" and me.combo2.value = "task1" then
me.combo2.defaultvalue = "task2"

both combo has limit to list property though the "task2" is still in the list

What's the context? Do you have an existing record you're editing, or do you
want to set the default value after Combo1 and Combo2 have been selected?
What's the context? Are you setting the default value so that future records
will be task2?

I would expect that the AfterUpdate events of the two combo boxes would be the
appropriate place, and that rather than setting the DefaultValue property you
could just push "Task2" into the combo box:

Private Sub combo1_AfterUpdate()
If Me!combo1 = "depart1" AND Me!combo2 = "task1" Then
Me!combo2.DefaultValue = """task2"""
End If
End Sub

The triplequotes are to set the default value to a quoted string "task2".
 
S

sobeit via AccessMonster.com

thank you much John
What's the context? Do you have an existing record you're editing, or do you
want to set the default value after Combo1 and Combo2 have been selected?
What's the context? Are you setting the default value so that future records
will be task2?

I would expect that the AfterUpdate events of the two combo boxes would be the
appropriate place, and that rather than setting the DefaultValue property you
could just push "Task2" into the combo box:

Private Sub combo1_AfterUpdate()
If Me!combo1 = "depart1" AND Me!combo2 = "task1" Then
Me!combo2.DefaultValue = """task2"""
End If
End Sub

The triplequotes are to set the default value to a quoted string "task2".
 
Top