D
dorji dukpa
i have a main form and a sub form linked by Master/Child fileds. i have my navigation buttons, which are enabled/disabled by the function below:
Public Sub EnableButtons(frm As Form)
On Error GoTo Err_EnableButtons
Set rst = frm.RecordsetClone
If frm.NewRecord Then
frm!cmdPrevious.Enabled = True And (rst.RecordCount > 0)
frm!cmdFirst.Enabled = True And (rst.RecordCount > 0)
frm!cmdLast.Enabled = False
frm!CmdNext.Enabled = False
frm!cmdAdd.Enabled = False
frm!cmdDelete.Enabled = False 'Cannot delete when you are still at new record.
Else
frm!cmdDelete.Enabled = True 'Enable delete if not new record.
frm!cmdAdd.Enabled = True
rst.Bookmark = frm.Bookmark
rst.MovePrevious
frm!cmdFirst.Enabled = Not rst.BOF
frm!cmdPrevious.Enabled = Not rst.BOF
rst.Bookmark = frm.Bookmark
rst.MoveNext
frm!cmdLast.Enabled = Not (rst.EOF Or frm.NewRecord)
frm!CmdNext.Enabled = Not (rst.EOF Or frm.NewRecord)
End If
Exit_EnableButtons:
Exit Sub
Err_EnableButtons:
MsgBox Err.Description
Resume Exit_EnableButtons
End Sub
this function is placed on the On_Cuurent event of the main form. my problem is whenever i try to add a new record on the main form, as soon as i type the first character, the sub form shows the data from the previous record.
thanks
Dorji
Public Sub EnableButtons(frm As Form)
On Error GoTo Err_EnableButtons
Set rst = frm.RecordsetClone
If frm.NewRecord Then
frm!cmdPrevious.Enabled = True And (rst.RecordCount > 0)
frm!cmdFirst.Enabled = True And (rst.RecordCount > 0)
frm!cmdLast.Enabled = False
frm!CmdNext.Enabled = False
frm!cmdAdd.Enabled = False
frm!cmdDelete.Enabled = False 'Cannot delete when you are still at new record.
Else
frm!cmdDelete.Enabled = True 'Enable delete if not new record.
frm!cmdAdd.Enabled = True
rst.Bookmark = frm.Bookmark
rst.MovePrevious
frm!cmdFirst.Enabled = Not rst.BOF
frm!cmdPrevious.Enabled = Not rst.BOF
rst.Bookmark = frm.Bookmark
rst.MoveNext
frm!cmdLast.Enabled = Not (rst.EOF Or frm.NewRecord)
frm!CmdNext.Enabled = Not (rst.EOF Or frm.NewRecord)
End If
Exit_EnableButtons:
Exit Sub
Err_EnableButtons:
MsgBox Err.Description
Resume Exit_EnableButtons
End Sub
this function is placed on the On_Cuurent event of the main form. my problem is whenever i try to add a new record on the main form, as soon as i type the first character, the sub form shows the data from the previous record.
thanks
Dorji