D
dhstein
I have 2 forms. Form A has a combo box. When the user selects the value, I
capture the value, open form B and attempt to set a textbox on formB to that
value. Here is the code:
' Code Start *********************
Private Sub cbxNewProduct_AfterUpdate()
Dim Category As String
Dim NextSKU As String
Category = cbxNewProduct.Value
NextSKU = DLookup("LastEntry", "tblCategories", "ID = " & Category & "")
NextSKU = CStr(Val(NextSKU) + 1)
On Error GoTo cbxNewProduct_AfterUpdate_Err
cbxNewProduct.Value = ""
DoCmd.OpenForm "frmNewProduct"
frmNewProduct.tbxProductSKU.Value = NextSKU
cbxNewProduct_AfterUpdate_Exit:
Exit Sub
cbxNewProduct_AfterUpdate_Err:
MsgBox Error$
Resume cbxNewProduct_AfterUpdate_Exit
End Sub
'Code End **********************
I am getting this error in a message box format:
Microsoft Office Access
Object Required
I tried to set breakpoints, but it isn't clear to me where I'm getting this
error. I'm pretty sure it's on the OpenForm command.
After I wrote the above - I did some more investigation. Form B was copied
from another form that was bound to a table. I wanted to get many of the
same boxes and similar layouts which is why I did that. Form B has all
unbound controls, but the form itself shows the table as the record source.
I can't remove that - it seems to be requiring a record source for the form.
So if there is an easy way to change that thanks, otherwise I will have to
delete the form and start from scratch.
capture the value, open form B and attempt to set a textbox on formB to that
value. Here is the code:
' Code Start *********************
Private Sub cbxNewProduct_AfterUpdate()
Dim Category As String
Dim NextSKU As String
Category = cbxNewProduct.Value
NextSKU = DLookup("LastEntry", "tblCategories", "ID = " & Category & "")
NextSKU = CStr(Val(NextSKU) + 1)
On Error GoTo cbxNewProduct_AfterUpdate_Err
cbxNewProduct.Value = ""
DoCmd.OpenForm "frmNewProduct"
frmNewProduct.tbxProductSKU.Value = NextSKU
cbxNewProduct_AfterUpdate_Exit:
Exit Sub
cbxNewProduct_AfterUpdate_Err:
MsgBox Error$
Resume cbxNewProduct_AfterUpdate_Exit
End Sub
'Code End **********************
I am getting this error in a message box format:
Microsoft Office Access
Object Required
I tried to set breakpoints, but it isn't clear to me where I'm getting this
error. I'm pretty sure it's on the OpenForm command.
After I wrote the above - I did some more investigation. Form B was copied
from another form that was bound to a table. I wanted to get many of the
same boxes and similar layouts which is why I did that. Form B has all
unbound controls, but the form itself shows the table as the record source.
I can't remove that - it seems to be requiring a record source for the form.
So if there is an easy way to change that thanks, otherwise I will have to
delete the form and start from scratch.