LtDan
LtDan

Reputation:

How to open a second form based on info from first form?

Could someone please help me with the IF-syntax below?

This is what we need to do:

  1. Add a new record on Form1;
  2. Click a button on Form1 to open Form2;
  3. When Form2 opens, it contains info from Form1.

So, I add this to Properties/OnDirty/CodeBuilder:

If me.Dirty = True then 
  Me.Dirty = false
Docmd.OpenForm "Form2",,,"EvalID = " & me!Eval_ID 

As soon as I enter data, the Docmd line creates a

run-time error 3075, syntax error (missing operator)...EvalID

In Form1 the key is Eval_ID and in Form2 I have EvalID (but not not the key).

Any suggestions?

Upvotes: 0

Views: 3666

Answers (1)

JesseBechtold
JesseBechtold

Reputation: 21

It looks to me like there are a few things going on here. It would also help to confirm some information:

  1. Is this referring to a MS Access form or some other VBA-driven form?
  2. Are both forms bound to tables or editable queries?

This isn't likely the issue causing the syntax error. It should be simple enough to resolve that. Put a breakpoint in the code at that location. At that point, copy the resulting string (e.g. EvalID = 7) after the word "WHERE" in the SQL view of a new query based on the two tables. Preview the query to debug the cause of the problem with that expression.

Upvotes: 1

Related Questions