M
mbaycura
I'm trying to use a macro that will run when a button is clicked that will
open a different form and set the ID value of the new forms record to the
same value as the original form ID number.
I created a macro group called "NewNPI" which is called when the button is
clicked.
this macro is the following.
SetTempvar ---- NPITemp, [ID]
OpenForm ---- NPI Entry, Form,,,,Normal
SearchForRecord ----,,First, ID=[TempVars]![NPITemp]
condition [ID]<0 ----- SetValue ---- [ID], [TempVars]![NPITemp]
RemoveTempVar --- NPITemp
the idea is that it sets a temp variable to the original forms record ID
then opens the new form, goes to a new record, then searches to see if a
record already exists with that number, if this comes back false, according
to the help this should stay on the current record which would be new. then
sets the current, new record ID to the temp var and removes the tempvar. I
had a condition that was if ID<1 so that it would not overwrite the record ID
if it does find one with the Tempvar value. But with or without the
condition it goes to the new record and stays there without updating the ID
of the new form properly with TempVar before removing it.
The key column is called ID for both the original form and the new form.
When I try to use SetValue with the full path [NPI Entry].[ID] or [NPI
Entry]![ID], I get an automation error. When I step through as is above
there are no errors, but the vaule in ID does not populate. However I have a
dummy unbound text box that populates correctly with the original forms ID
record value.
Help, PLEASE!
thanks.
open a different form and set the ID value of the new forms record to the
same value as the original form ID number.
I created a macro group called "NewNPI" which is called when the button is
clicked.
this macro is the following.
SetTempvar ---- NPITemp, [ID]
OpenForm ---- NPI Entry, Form,,,,Normal
SearchForRecord ----,,First, ID=[TempVars]![NPITemp]
condition [ID]<0 ----- SetValue ---- [ID], [TempVars]![NPITemp]
RemoveTempVar --- NPITemp
the idea is that it sets a temp variable to the original forms record ID
then opens the new form, goes to a new record, then searches to see if a
record already exists with that number, if this comes back false, according
to the help this should stay on the current record which would be new. then
sets the current, new record ID to the temp var and removes the tempvar. I
had a condition that was if ID<1 so that it would not overwrite the record ID
if it does find one with the Tempvar value. But with or without the
condition it goes to the new record and stays there without updating the ID
of the new form properly with TempVar before removing it.
The key column is called ID for both the original form and the new form.
When I try to use SetValue with the full path [NPI Entry].[ID] or [NPI
Entry]![ID], I get an automation error. When I step through as is above
there are no errors, but the vaule in ID does not populate. However I have a
dummy unbound text box that populates correctly with the original forms ID
record value.
Help, PLEASE!
thanks.