Form/Subform Problems

C

Confused

Customers/Inventory

1) On the main form, (Customers)I need to lock some controls, but keep some
combo boxes unlocked that I use for searching. But I need the fields
unlocked when on a new record. The subform doesn't need to be locked. I
found this, but it doesn't unlock the combo34 except on new records, which is
what the code does to all of the controls.

Private Sub Form_Current()
Dim ctrl As Control

On Error Resume Next
If Me.NewRecord Then
For Each ctrl In Me.Controls
ctrl.Locked = False
Next ctrl
Else
For Each ctrl In Me.Controls
ctrl.Locked = (ctrl.Name <> "combo34")
Next ctrl
End If


End Sub

2) I have the main form and subform tied together by Customer ID. When I go
to a new record, I try to click down a combo box with the Customer Names
bound to customer ID. It then tells me "Cannot edit field it's bound to an
auto number Customer ID. So how would I add records?

3) When I advance records, if a customer has, say four items in inventory,
I have to flip through four instances of the same record before it advances
to the next customer.
 
C

Confused

Arvin- I tried the following code, and I get "Object Required." Can you
tell what I'm missing? Thank you!

Private Sub Command45_Click()
On Error GoTo Err_Command45_Click
Dim ctl As Control

For Each ctl In frm.Controls
With ctl

Select Case .ControlType
Case acCommandButton

If ctl.Tag = 2 Then
ctl.Locked = True

End If

End Select
End With

Next ctl

Set ctl = Nothing
Set frm = Nothing



Dcmd.GoToRecord , , acNew




MsgBox "Select Name From Clec Name at the top"






Exit_Command45_Click:
Exit Sub

Err_Command45_Click:
MsgBox Err.Description
Resume Exit_Command45_Click

End Sub
 
A

Arvin Meyer MVP

You haven't dim'd frm.

Why don't you put the LockIt sunroutine in a module named something like
basUtilities, then call LockIt (Me) in the form's Current event? Do it like
this:

Private Sub Form_Current()
LockIt(Me)
End Sub

You can also do it from a command button:

Private Sub Command45_Click()
LockIt(Me)
End Sub
 

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