Hello to anyone who takes a look at my problem. Thanks in advance.
Well, here is my problem. I have a table that stores names. It is connected to other forms as a list box to choose the names from. What I would like to do is have a input box open up once a cmd button is clicked. The user will then enter a name within the box and it will post into the table once OK is clicked, allowing the user to select it from a list. Here is my code but nothing happens except for the input. I have no idea where the data is going. (Names is the table and because this is a testing mdb the field is also named Names) I am pretty sure it would work with a few chages in VB but I can not figure it out in VBA.
Private Sub Add_Data_Click()
Dim Varanswer As String
Dim rst As DAO.Recordset
Dim One As String
Varanswer = InputBox("Please Enter the Name which you would like to add."
If Varanswer = "1" Then
Set rst = CurrentDb.OpenRecordset(Names, dbOpenDynaset)
One = Varanswer
With rst
.AddNew
!Names = Me!Names.Column(0, One)
.update
End With
End If
End Sub
Any help would be greatly appreciated.
Tofias1
Well, here is my problem. I have a table that stores names. It is connected to other forms as a list box to choose the names from. What I would like to do is have a input box open up once a cmd button is clicked. The user will then enter a name within the box and it will post into the table once OK is clicked, allowing the user to select it from a list. Here is my code but nothing happens except for the input. I have no idea where the data is going. (Names is the table and because this is a testing mdb the field is also named Names) I am pretty sure it would work with a few chages in VB but I can not figure it out in VBA.
Private Sub Add_Data_Click()
Dim Varanswer As String
Dim rst As DAO.Recordset
Dim One As String
Varanswer = InputBox("Please Enter the Name which you would like to add."
If Varanswer = "1" Then
Set rst = CurrentDb.OpenRecordset(Names, dbOpenDynaset)
One = Varanswer
With rst
.AddNew
!Names = Me!Names.Column(0, One)
.update
End With
End If
End Sub
Any help would be greatly appreciated.
Tofias1