G
gt
Hi folks:
I'm using automation to create a new record in an Access table w/ this code:
objAccess.CurrentDb.Execute "INSERT INTO Letters (followed by the fields and
corresponding values). This works fine.
Immediately after that snippet of code I want to open an unbound form
(called cbScreen) in the same db and display the record just created. I've
tried two approaches, shown below, both of which generate errors. Any advice
would be greatly appreciated.
Approach 1:
objAccess.DoCmd.OpenForm "cbscreen", , , "doc" = """ & GBASdoc & """
This approach generates run-time error 2491: The action or method is invalid
because the form or report isn't bound to a table or query. (and I don't want
to bind it)
Approach 2:
strSQL = "SELECT * From letters WHERE (doc) = """ & GBASDoc & """;"
Forms![cbScreen].RecordSource = strSQL
This approach generates the runtime error 462: The remote server machine
does not exist or is unavailable. (it's also generated another error -
Microsoft Access can't find the form...)
Is there a better way to open a specific form and populate it w/ a specific
record - via automation?
Thanks, gt
I'm using automation to create a new record in an Access table w/ this code:
objAccess.CurrentDb.Execute "INSERT INTO Letters (followed by the fields and
corresponding values). This works fine.
Immediately after that snippet of code I want to open an unbound form
(called cbScreen) in the same db and display the record just created. I've
tried two approaches, shown below, both of which generate errors. Any advice
would be greatly appreciated.
Approach 1:
objAccess.DoCmd.OpenForm "cbscreen", , , "doc" = """ & GBASdoc & """
This approach generates run-time error 2491: The action or method is invalid
because the form or report isn't bound to a table or query. (and I don't want
to bind it)
Approach 2:
strSQL = "SELECT * From letters WHERE (doc) = """ & GBASDoc & """;"
Forms![cbScreen].RecordSource = strSQL
This approach generates the runtime error 462: The remote server machine
does not exist or is unavailable. (it's also generated another error -
Microsoft Access can't find the form...)
Is there a better way to open a specific form and populate it w/ a specific
record - via automation?
Thanks, gt