dwAccessUser32
Programmer
I have a form that allows a user to enter information on a person. One of the pieces of information that is collected is the phone number of the person. It does this with 4 different text boxes:
txtHome
txtWork
txtMobile
txtFax
The problem is that when there is no record for a person the textboxes vanish as I scroll through 10 or so different entries on the form.
The code to generate the 4 different phone number textboxes is shown below:
Private Sub Form_Current()
Dim rs As New ADODB.Recordset
Dim i As Integer
If Me.NewRecord And IsNull(Me.PersonID) Then Exit Sub
If DCount("PersonID", "tblPhoneNumbers", "[PersonID] = " & Me.PersonID) = 0 Then
rs.Open "tblPhoneNumbers", CurrentProject.Connection, adOpenDynamic, adLockOptimistic
For i = 1 To DCount("*", "tluPhoneNumberTypes")
rs.AddNew
rs!PhoneNumberTypeID = i
rs!PersonID = Me.PersonID
rs.Update
Next i
Me.[tblPhoneNumbers subform7].Requery
End If
End Sub
And the code that I tried to get to work for creating the textboxes if no PersonID record exists doesn't work:
Private Sub List131_AfterUpdate()
Me.Dirty = False
Call Form_Current
End Sub
List131 is a listbox that lets a user select the category of person (e.g., salesman, manager, etc.)
Can anyone offer any advice on how to solve this problem? Again, the problem is that when I open the form and browse through the 10 or so different records the textboxes are fine and fill with values that come from the database. However, as soon as no PersonID from tblPeople exists the 4 textboxes disappear and I cannot enter a value to create a new record.
Any advice would be greatly appreciated.
Thanks!
txtHome
txtWork
txtMobile
txtFax
The problem is that when there is no record for a person the textboxes vanish as I scroll through 10 or so different entries on the form.
The code to generate the 4 different phone number textboxes is shown below:
Private Sub Form_Current()
Dim rs As New ADODB.Recordset
Dim i As Integer
If Me.NewRecord And IsNull(Me.PersonID) Then Exit Sub
If DCount("PersonID", "tblPhoneNumbers", "[PersonID] = " & Me.PersonID) = 0 Then
rs.Open "tblPhoneNumbers", CurrentProject.Connection, adOpenDynamic, adLockOptimistic
For i = 1 To DCount("*", "tluPhoneNumberTypes")
rs.AddNew
rs!PhoneNumberTypeID = i
rs!PersonID = Me.PersonID
rs.Update
Next i
Me.[tblPhoneNumbers subform7].Requery
End If
End Sub
And the code that I tried to get to work for creating the textboxes if no PersonID record exists doesn't work:
Private Sub List131_AfterUpdate()
Me.Dirty = False
Call Form_Current
End Sub
List131 is a listbox that lets a user select the category of person (e.g., salesman, manager, etc.)
Can anyone offer any advice on how to solve this problem? Again, the problem is that when I open the form and browse through the 10 or so different records the textboxes are fine and fill with values that come from the database. However, as soon as no PersonID from tblPeople exists the 4 textboxes disappear and I cannot enter a value to create a new record.
Any advice would be greatly appreciated.
Thanks!