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 biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Refreshing a combo box 1

Status
Not open for further replies.

Secretgeek

Technical User
Jan 3, 2008
80
GB
Good afternoon,

This may be better off in the VBA Code Forum. If so I apologise.

I have a control - 'Legislation' -that when a certain value is selected - 'DPA' - two dates are calculated, another control 'FOIType'(a combobox) has it's value set to "n/a" and the focus moves to another control.

The problem is that when 'DPA' is selected the two dates show immediately in their boxes but 'FOIType' remains blank. Moving to the next record and back again shows that the value is being set correctly it's just not being shown.

I've tried Refresh, Requery and Repaint and I'm either getting type mismatch errors or nothing at all and I'm starting to have a brain melt down. Any help would be much appreciated. Here is my code as it stands at the moment:

[blue] Private Sub Legislation_Change()

If Me!Legislation Like "FOI*" Or Me!Legislation Like "EIR" Then

Call basMgtDate(20, [NCC Date Received])
Me![DPA Type] = "n/a"
Me![DPA Stage] = "n/a"

Else

If Me!Legislation Like "DPA" Then

Me![FOI Type] = "n/a"
Me![IGO Deadline] = DateAdd("d", 40, [NCC Date Received])
Me![Dept Deadline] = DateAdd("d", 20, [NCC Date Received])
Me![DPA Type].SetFocus

End If

End If

End Sub [/blue]

Thanks in advance for your help.
 
How are ya Secretgeek . . .

Try this:
Code:
[blue]   If Me!Legislation Like "FOI*" Or Me!Legislation Like "EIR" Then

      [green]'Your Code[/green]    
   ElseIf Me!Legislation Like "DPA" Then
      [green]'Your Code[/green]
   End If

   If Me.Dirty then Me.Dirty = False[/blue]

Calvin.gif
See Ya! . . . . . .

Be sure to see thread181-473997
Also faq181-2886
 
Hi Ace,

Tried your suggestion, no change I'm afraid. It's still doing everything except showing the 'n/a'

Tried sticking a Me.Repaint after your "If Me.Dirty..." line and still nothing.
 
what is the rowsource of your combo box.

RE: Me![FOI Type] = "n/a"

will only work if "n/a" represents the bound column. What is the bound column of your combo box? If "n/a" has an ID number that the combo box is bound to (say 1), then:

Me.[FOI Type] = 1


.....
I'd rather be surfing
 
Secretgeek . . .

So sorry . . . the [blue]Dirty[/blue] line should come before [blue]If Then[/blue] . . .

Calvin.gif
See Ya! . . . . . .

Be sure to see thread181-473997
Also faq181-2886
 
Sorry it's taken me so long to report back. Busy busy at the mo.

Ace - Moved the[blue] Dirty [/blue]line. No difference.

Jordan - RowSource is a value list specified as "n/a";"Too Vague";etc etc

The problem seems to be in the refresh of this specific control. Other combo boxes working with different procedures on the same form work fine.

Hmm...actually that gives me an idea. I'm going to change the target of my procedure to one of the other combo boxes to see if the problem occurs with that.

Back in a bit......
 
Secretgeek . . .

Try this:
Code:
[blue]Me![FOI Type].SetFocus
Me![FOI Type].text = "n/a"[/blue]

Calvin.gif
See Ya! . . . . . .

Be sure to see thread181-473997
Also faq181-2886
 
Thanks Ace but that's giving me an 'Object doesn't support this property or method' error on the SetFocus line.

Actually looking at it the only thing that Me![FOI Type] does seem to support is .Value At least that's the only option it's giving me when I add the '.' to Me![FOI Type]

Hmm...does this mean I'm missing a reference library or does it mean that Me![FOI Type] is not a proper combo box?

Starting to wish that I'd had the opportunity to build this database from scratch instead of having to work with what was already there.

If wishes were horses.....
 
Secretgeek . . .

[blue]Actually looking at it the only thing that Me![FOI Type] does seem to support is .Value At least that's the only option it's giving me when I add the '.' to Me![FOI Type][/blue]
[blue]There's certainly more properties to a combobox than that![/blue] Delete and reconstitute the combobox . . . then check those properties again.

Also, I noticed in your post origination your using the [blue]Change[/blue] event of [blue]Legislation[/blue]. The [purple]AfterUpdate[/purple] event would be better.

Calvin.gif
See Ya! . . . . . .

Be sure to see thread181-473997
Also faq181-2886
 
And the Ace scores!

Unfortunately I did both of your suggestions so I don't know which one it was that did the trick (schoolboy error I know) but the important thing in this case is that it has.

I suspect it was rebuilding the combobox that did it as all the properties are now available as well.

Thanks!

Andrew
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top