G
Guest
Hi,
I have a form where I am adding records. There are two boxes where one has
to put the lineitemnumber and another box where one has to put the
description. Unless the above two boxes are filled in the Add command box
need to be disabled. Now, the problem is after adding one record the Add
button is enabled and I cannot disable it. I would appreciate any help to
solve this.
The error message is:
The methos is not supported
The following is the code:
Private Sub cmdadd_Click()
On Error GoTo Err_cmdadd_Click
If (IsNull(Me.LineItemID) = True) Or (IsNull(Me.Description) = True) Then
MsgBox ("You cannot save null values to the system")
End If
Dim db As Database
Dim rstApp As Recordset
Dim strSQL As String
Dim strLineItemID As String
Set db = CurrentDb
Set rstApp = db.OpenRecordset("tblLineItems", dbOpenDynaset)
strLineItemID = Trim(Me.LineItemID)
If MsgBox("OK to Add " & strLineItemID & " ?", vbYesNo, "Confirm Add") =
vbYes Then
With rstApp
.AddNew
!LineItemID = Me.LineItemID
!Description = Me.Description
strSQL = "SELECT [tblLineItems].[LineItemID],
[tblLineItems].[Description] FROM tblLineItems order by tblLineItems"
.Update
MsgBox ("Records added to system")
End With
Else
MsgBox "Add Cancelled"
End If
Forms![frmAddLineItems]![LineItemID] = ""
Forms![frmAddLineItems]![Description] = ""
Me!LineItemID.SetFocus = True
Me!cmdadd.Enabled = False
Exit Sub
Exit_cmdadd_Click:
Exit Sub
Err_cmdadd_Click:
MsgBox Err.Description
Resume Exit_cmdadd_Click
End Sub
I have a form where I am adding records. There are two boxes where one has
to put the lineitemnumber and another box where one has to put the
description. Unless the above two boxes are filled in the Add command box
need to be disabled. Now, the problem is after adding one record the Add
button is enabled and I cannot disable it. I would appreciate any help to
solve this.
The error message is:
The methos is not supported
The following is the code:
Private Sub cmdadd_Click()
On Error GoTo Err_cmdadd_Click
If (IsNull(Me.LineItemID) = True) Or (IsNull(Me.Description) = True) Then
MsgBox ("You cannot save null values to the system")
End If
Dim db As Database
Dim rstApp As Recordset
Dim strSQL As String
Dim strLineItemID As String
Set db = CurrentDb
Set rstApp = db.OpenRecordset("tblLineItems", dbOpenDynaset)
strLineItemID = Trim(Me.LineItemID)
If MsgBox("OK to Add " & strLineItemID & " ?", vbYesNo, "Confirm Add") =
vbYes Then
With rstApp
.AddNew
!LineItemID = Me.LineItemID
!Description = Me.Description
strSQL = "SELECT [tblLineItems].[LineItemID],
[tblLineItems].[Description] FROM tblLineItems order by tblLineItems"
.Update
MsgBox ("Records added to system")
End With
Else
MsgBox "Add Cancelled"
End If
Forms![frmAddLineItems]![LineItemID] = ""
Forms![frmAddLineItems]![Description] = ""
Me!LineItemID.SetFocus = True
Me!cmdadd.Enabled = False
Exit Sub
Exit_cmdadd_Click:
Exit Sub
Err_cmdadd_Click:
MsgBox Err.Description
Resume Exit_cmdadd_Click
End Sub