changing form properties programatically - Access 2000

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

Guest

I'm using the following code to enable listbox lstVendor depending on input from listbox lstType. LstVendor is not enabled when I first see the form, is enabled when I choose the 2nd in lstType. But when I tab out of lstType to lstVendor the IOCNumber in the Open event goes to zero (It increments correctly except under the conditions I've described). Can anyone tell me what is happening? Thx, Robbie

Private Sub Form_Open(Cancel As Integer)

DoCmd.GoToRecord , , acNewRec
Me.IOCNumber = Nz(DMax("[IOCNumber]", "[tblIOCLog]", ""), 0) + 1
Me.lstVendor.Enabled = False

End Sub

'Enable certain fields depending on choice of type from lstType
Private Sub lstType_Exit(Cancel As Integer)

Dim i As Integer
If Me.lstType = 2 Then
Me.lstVendor.Enabled = True
End If

End Sub
 
I think my problem has to do with updating two tables. My main table (the one my form is based on) is tblIOCLog. It is joined by combination primary key on fields IOCYear and IOCNumber to tblClient Approved Supplier. I think tblClientApproved Supplier with primary key ClientApprovedSupplierID has no record and needs one. Could this be my problem? How do I fix it?

----- Robbie M wrote: ----

I'm using the following code to enable listbox lstVendor depending on input from listbox lstType. LstVendor is not enabled when I first see the form, is enabled when I choose the 2nd in lstType. But when I tab out of lstType to lstVendor the IOCNumber in the Open event goes to zero (It increments correctly except under the conditions I've described). Can anyone tell me what is happening? Thx, Robbi

Private Sub Form_Open(Cancel As Integer

DoCmd.GoToRecord , , acNewRe
Me.IOCNumber = Nz(DMax("[IOCNumber]", "[tblIOCLog]", ""), 0) +
Me.lstVendor.Enabled = Fals

End Su

'Enable certain fields depending on choice of type from lstTyp
Private Sub lstType_Exit(Cancel As Integer

Dim i As Integer
If Me.lstType = 2 The
Me.lstVendor.Enabled = Tru
End I

End Sub
 
Back
Top