Dialog not writing records correctly

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a sub form with a command button that invokes a dialog.

When there are matching records (QuestionID) in the table the dialog is
populated correctly but, any records that are added to the dialog are written
to the table with QuestionID of 0 (zero) instead of the current QuestionID.

The code for the on click event is
Dim sWhere As String

Me![fiQuestionLvl3].SetFocus
sWhere = "[QuestionID] = " & Str(QuestionID)
'MsgBox "1 | " & sWhere
DoCmd.OpenForm "fSrvResponseList", , , sWhere, , A_DIALOG, Str(QuestionID)

Any ideas please.
 
The WhereCondition will work only on existing records, to populate new
records use the OpenArgs parameter you are sending.

DoCmd.OpenForm "fSrvResponseList", , , sWhere, , A_DIALOG, QuestionID


On the OnLoad evet of the fSrvResponseList form, write the code

If Me.NewRecord And Not IsNull(Me.OpenArgs) Then
Me.[QuestionID] = Me.OpenArgs
End If
 
Thanks for that Ofer
--
Graham


Ofer Cohen said:
The WhereCondition will work only on existing records, to populate new
records use the OpenArgs parameter you are sending.

DoCmd.OpenForm "fSrvResponseList", , , sWhere, , A_DIALOG, QuestionID


On the OnLoad evet of the fSrvResponseList form, write the code

If Me.NewRecord And Not IsNull(Me.OpenArgs) Then
Me.[QuestionID] = Me.OpenArgs
End If


--
Good Luck
BS"D


Graham said:
I have a sub form with a command button that invokes a dialog.

When there are matching records (QuestionID) in the table the dialog is
populated correctly but, any records that are added to the dialog are written
to the table with QuestionID of 0 (zero) instead of the current QuestionID.

The code for the on click event is
Dim sWhere As String

Me![fiQuestionLvl3].SetFocus
sWhere = "[QuestionID] = " & Str(QuestionID)
'MsgBox "1 | " & sWhere
DoCmd.OpenForm "fSrvResponseList", , , sWhere, , A_DIALOG, Str(QuestionID)

Any ideas please.
 
Back
Top