G
Guest
Hi, Please help...
I am trying to create a command button that will add new record to my table
of data, and once the data is input i have a submit button to confirm that
all is well. I and the autonumber function to add the new record in the
table. I want to have a input box when I click add new record to add the ID
number of the person I am entering data for. This below is my code I have
which doesnt seem to be working for some reason...
Thanks, Jez
Private Sub btnCreateNewInput_Click()
varInput = InputBox("Enter the RPSGB Reg No", "Add new Data")
DoCmd.SetWarnings False
DoCmd.RunSQL "INSERT INTO tblData (RPSGBRegNo) " & _
"VALUES ('" & varInput & "')"
varNewID = DLookup("max(FormNumber)", "tblData")
Me.RecordSource = "SELECT tblData.* FROM tblData WHERE " & _
"tblData.FormNumber = " & varNewID & ";"
Call UnLockAll
Me.txtFormNo.RowSource = "SELECT tblData.FormNumber,
tblData.RPSGBRegNo, tblData.Pharmacist, tblData.Pharmacy, " & _
"tblData.NACSCode, tblData.ContractorCode, tblData.Postcode " & _
"FROM tblData"
With Me
.RecordSource = sQRY
.RowSource = sQRY
Me.txtFormNo.Enabled = True
Me.txtFormNo.Requery
Me.txtDummy.SetFocus
Me.cmdSubmit.Visible = True
End With
End Sub
I am trying to create a command button that will add new record to my table
of data, and once the data is input i have a submit button to confirm that
all is well. I and the autonumber function to add the new record in the
table. I want to have a input box when I click add new record to add the ID
number of the person I am entering data for. This below is my code I have
which doesnt seem to be working for some reason...
Thanks, Jez
Private Sub btnCreateNewInput_Click()
varInput = InputBox("Enter the RPSGB Reg No", "Add new Data")
DoCmd.SetWarnings False
DoCmd.RunSQL "INSERT INTO tblData (RPSGBRegNo) " & _
"VALUES ('" & varInput & "')"
varNewID = DLookup("max(FormNumber)", "tblData")
Me.RecordSource = "SELECT tblData.* FROM tblData WHERE " & _
"tblData.FormNumber = " & varNewID & ";"
Call UnLockAll
Me.txtFormNo.RowSource = "SELECT tblData.FormNumber,
tblData.RPSGBRegNo, tblData.Pharmacist, tblData.Pharmacy, " & _
"tblData.NACSCode, tblData.ContractorCode, tblData.Postcode " & _
"FROM tblData"
With Me
.RecordSource = sQRY
.RowSource = sQRY
Me.txtFormNo.Enabled = True
Me.txtFormNo.Requery
Me.txtDummy.SetFocus
Me.cmdSubmit.Visible = True
End With
End Sub