Data entered in form not showing on table

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a form, ProjectInfoForm that is based on the ProjectInfoTable and it
has a button that opens a linked form called ProjectTeamForm. The
ProjectTeamForm contains information found in the TeamMembersTable.

The user should be able to pick a name from the list or type in a new name.
The form allows users do that, however, it does not add the new name to the
TeamMembersTable.

How do I make the new entries get added to the table?

Thanks, Samantha
 
You might try something like this:

Public Sub AddToList(strFormName, strItem, NewData, Response)
'---------------------------------------------------------------------------
------------
' Procedure : AddToList
' Date : 10/31/2004 Revised
' Author : Arvin Meyer
' Purpose : Generic Not In List Code
' Usage : AddToList "YourFormName", "YourComboItem" NewData, Response
'---------------------------------------------------------------------------
------------
On Error GoTo Error_Handler

Dim intNewItem As Integer
Dim strMsgText As String
Dim intMsgArg As Integer
Dim strTitle As String

strMsgText = "This " & strItem & " is not in the list. Do you want to
add a new " & strItem & "?"
intMsgArg = vbYesNo + vbQuestion + vbDefaultButton1
strTitle = "Not In This List"
intNewItem = MsgBox(strMsgText, intMsgArg, strTitle)

If intNewItem = vbYes Then
DoCmd.RunCommand acCmdUndo
DoCmd.OpenForm strFormName, acNormal, , , acFormAdd, acDialog,
NewData
Response = acDataErrAdded
End If

Exit_Here:
Exit Sub

Error_Handler:
Call ErrorLog("basUtilities", "AddToList")
Resume Exit_Here

End Sub

In the form that opens to add the data, use the following code attached to
the control (in this case txtWhatever) which the data is going into:

Private Sub txtWhatever_GotFocus()
On Error Resume Next
If Me.NewRecord = True Then
Me.txtWhatever = Me.OpenArgs
Me.txtWhatever.SelStart = Me.txtWhatever.SelLength + 1
End If
End Sub

--
Arvin Meyer, MCP, MVP
Microsoft Access
Free Access downloads:
http://www.datastrat.com
http://www.mvps.org/access
 
Back
Top