ACCESS/VB

C

CLSWL

I am trying to automate a form in Access using VB code.

My problem is that I get the error that I can't hide to control that has the
focus. What should I do?

Here's the code.

Private Sub Model1_BeforeUpdate(Cancel As Integer)
Call ModCorrelation
End Sub

Private Sub Model1_AfterUpdate()
Call ModCleanse
Call ModCorrelation
End Sub

Public Function ModCorrelation()
'Affected Models
If IsNull(Combo_Mod0.Value) = True Then
Combo_Mod1.Visible = False
Combo_Mod2.Visible = False
Combo_Mod3.Visible = False
ElseIf IsNull(Combo_Mod0.Value) = False And IsNull(Combo_Mod1.Value) = True
Then
Combo_Mod1.Visible = True
Combo_Mod2.Visible = False
Combo_Mod3.Visible = False
ElseIf IsNull(Combo_Mod0.Value) = False And IsNull(Combo_Mod1.Value) = False
And IsNull(Combo_Mod2.Value) = True Then
Combo_Mod1.Visible = True
Combo_Mod2.Visible = True
Combo_Mod3.Visible = False
Else
Combo_Mod1.Visible = True
Combo_Mod2.Visible = True
Combo_Mod3.Visible = True
End If
End Function

Public Function ModCleanse()
If IsNull(Combo_Mod3.Value) = False And IsNull(Combo_Mod2.Value) = True Then
Combo_Mod2.Value = Combo_Mod3.Value
Combo_Mod3.Value = Null
End If
If IsNull(Combo_Mod2.Value) = False And IsNull(Combo_Mod1.Value) = True Then
Combo_Mod1.Value = Combo_Mod2.Value
Combo_Mod2.Value = Null
End If
If IsNull(Combo_Mod1.Value) = False And IsNull(Combo_Mod0.Value) = True Then
Combo_Mod0.Value = Combo_Mod1.Value
Combo_Mod1.Value = Null
End If
End Function
 
S

Skip

Do you have a handy control you can move the focus to before you hide the
other controls? If so, you could move the focus to that first. If not,
perhaps you could create a 'dummy' control to set the focus to.
 
C

CLSWL

I did try that and it works!

Different question:
Is there a handy way to use a multi-selct box in a form to auto-populate
several records? For example: I go to store A, in State B, and buy items C,
D, and E and i want to save it as
Store A, State B, Item C
Store A, State B, Item D
Store A, State B, Item E

How do i get a list box to do this?
1st I was going to to try 1 box that would let me multi-select. If it is
easier, I can also just have three item boxes appear one after the other.
The problem I have is the programming to save 3 diff records.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top