Set controlsource to fieldname

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

The textbox HNo1is set to unbound, when the user click to select "I" on combo
box CobDis1 then HNo1 will enable and I want recordsource to be set to fields
name "h_no". How can I do this? Thanks for all respond.

Private Sub CobDis1_AfterUpdate()
Dim rs As DAO.Databases
Set rs = CurrentDb.OpenRecordset("dbo_Case", dbOpenDynaset, dbSeeChanges)
If Me.CobDis1 = "I" Then
Me.HNo1.Enabled = True
Me.HNo1.ControlSource = rs.Field("h_no")
Else
Me.HNo1.Enabled = False
End If
End Sub
 
MN said:
The textbox HNo1is set to unbound, when the user click to select "I" on combo
box CobDis1 then HNo1 will enable and I want recordsource to be set to fields
name "h_no". How can I do this? Thanks for all respond.

Private Sub CobDis1_AfterUpdate()
Dim rs As DAO.Databases
Set rs = CurrentDb.OpenRecordset("dbo_Case", dbOpenDynaset, dbSeeChanges)
If Me.CobDis1 = "I" Then
Me.HNo1.Enabled = True
Me.HNo1.ControlSource = rs.Field("h_no")
Else
Me.HNo1.Enabled = False
End If
End Sub


Set the ControlSource property to a string that's the name
of the field:

Me.HNo1.ControlSource = "h_no"

Shouldn't also clear the ControlSource when you disable the
control.

OTOH, why are you doing this? Wouldn't it be just as
effective to just disable the control (or make it
invisible)?
 
Thanks Marshall,
The end user they want Hno1 always disable except when thay select
CobDis1="I" then it is enable.
Also, on screen design they have CobDis2 and HNo2, then they can select
either CobDis1 or Cobdis2="I" then just 1 of them enable! That tricky for
me...! So you solve the problem for me... thanks a lot.
MN
 
Back
Top