M
Mesa
First i would like to say thank you to this community group for
helping me through all my learnings of access. Also please forgive
any lateness in my response but i am not easily available to the
internet here.
Ok, i created a database in which i put a person in the main form and
on a subform i can select in a listbox a group and then click a button
to put them in that group. The subform uses a one to many table that
is linked to the main form. That field is an autonumber and named
"Record". On the subform table, there are two fields, "Network", and
"Record". What I am trying to do is limit a network in a record only
once. Each record can be in multiple networks but I dont want a
person to show that he is on the same network twice. In other words,
I want to restrict a network from being entered twice when i click on
the "Add Button". Here is my code so far
Private Sub Add_Button_Click()
On Error GoTo Err_Add_Button_Click
Me!Network.SetFocus
DoCmd.GoToRecord , , acNewRec
Me!Network.Value = Me![List Total].Value
If (Not IsNull(DLookup("[Network]", "(Networks)", "[Record] =" &
Forms![Main]!Record))) Then
MsgBox "This person is already in this network."
Me.Form.Undo
Else
If Len(Me![Network].Text & "") = 0 Then
DoCmd.SetWarnings False
RunCommand acCmdDeleteRecord
DoCmd.SetWarnings True
Me.Form.Refresh
Else
Me.Form.Refresh
End If
End If
Exit_Add_Button_Click:
Exit Sub
Err_Add_Button_Click:
MsgBox Err.Description
Resume Exit_Add_Button_Click
End Sub
the problem I am having is that it will let me enter only one network
in the subform. I want to have the dlookup check the "Network" table
on the "Network" field per record linked by the main form if the
network I selected is already linked to the person. If the dlookup
finds that there is a match in the "Network" field with the same
"Record" field value, then the msgbox will apear and undo will
continue.
helping me through all my learnings of access. Also please forgive
any lateness in my response but i am not easily available to the
internet here.
Ok, i created a database in which i put a person in the main form and
on a subform i can select in a listbox a group and then click a button
to put them in that group. The subform uses a one to many table that
is linked to the main form. That field is an autonumber and named
"Record". On the subform table, there are two fields, "Network", and
"Record". What I am trying to do is limit a network in a record only
once. Each record can be in multiple networks but I dont want a
person to show that he is on the same network twice. In other words,
I want to restrict a network from being entered twice when i click on
the "Add Button". Here is my code so far
Private Sub Add_Button_Click()
On Error GoTo Err_Add_Button_Click
Me!Network.SetFocus
DoCmd.GoToRecord , , acNewRec
Me!Network.Value = Me![List Total].Value
If (Not IsNull(DLookup("[Network]", "(Networks)", "[Record] =" &
Forms![Main]!Record))) Then
MsgBox "This person is already in this network."
Me.Form.Undo
Else
If Len(Me![Network].Text & "") = 0 Then
DoCmd.SetWarnings False
RunCommand acCmdDeleteRecord
DoCmd.SetWarnings True
Me.Form.Refresh
Else
Me.Form.Refresh
End If
End If
Exit_Add_Button_Click:
Exit Sub
Err_Add_Button_Click:
MsgBox Err.Description
Resume Exit_Add_Button_Click
End Sub
the problem I am having is that it will let me enter only one network
in the subform. I want to have the dlookup check the "Network" table
on the "Network" field per record linked by the main form if the
network I selected is already linked to the person. If the dlookup
finds that there is a match in the "Network" field with the same
"Record" field value, then the msgbox will apear and undo will
continue.