New problem I can't solve!
I have two forms. One creates a new record, populating certain fields. The other is the main form. These are not parent/sub forms.
I want to go from the create record form to the main form ending up on the newly created record AND NOT have the filter on.
I have other databases where I click a button and go to a specific record on another form, but it ends up just displaying the matching record and I have to turn off the filter to see or find any other records.
The people using this new database are not "database people" and won't know that the filter has to be turned off nor will they remember to click a button to remove the filter.
The Main form is not sorted by the primary key, but I'm using the primary key to find the last record created.
I have run in circles for two hours!
Here's what I have:
Code:
If MsgBox("New Widget Created!" & vbCrLf & vbCrLf & "Would you like to open the new record?", vbYesNo + vbQuestion, "New Widget Created!") = vbYes Then
LastOne = DMax("WidgetAutoID", "tbl_MasterWidgetData")
Debug.Print LastOne
lastRec = "[WidgetAutoID] = " & LastOne
Debug.Print lastRec
'DoCmd.OpenForm "frm_MasterwidgetData", "WidgetAutoID =" & LastOne <<--throws a "type mismatch" error
'DoCmd.FindRecord "WidgetAutoID =" & LastOne <<--- Does show the last record created, but applies a filter and ONLY shows this record
'DoCmd.GoToRecord acDataForm, "frm_MasterWidgetData", "[WidgetAutoID] = " & LastOne & "" <<--- throws a "type mismatch" error
'DoCmd.GoToRecord acDataForm, "frm_MasterWidgetData", LastOne <<--throws an error "expression in argument three invaild
'DoCmd.GoToRecord acDataForm, "frm_MasterWidgetData", lastRec <<--throws a "type mismatch" error
Else
End If
The "LastOne" variable is defined as an integer and the "WidgetAutoID" field is an autonumber ... is that the issue? if so, what should the LastOne variable be defined as?
I also defined "lastRec" as a string, but had the same issues ... type mismatch.
This seems so simple!
Susie
Kansas