Adding a Record

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

Guest

I have 2 Subforms on my Main form.

Each Subform contains a combo box with drop-down list. Their tables are on
the many side of the one-to-many relationship with the Main form.

When I make a selection on Subform 1, Subform 2 automatically populates with
a correlated item from its drop-down list.

PROBLEM: when I make a SECOND selection on Subform 1, the item that was
listed on Subform 2 gets replaced with the item correlating with the SECOND
selection.

How can I adjust my code so that the second item is ADDED to the list on
Subform 2 instead of replacing the first item?

A sample of the code to automatically populate Subform 2:

If InStr(1, Me.Combo1.Value, "Spreadsheet") > 0 Then
Me.Parent![Application].Form.Combo2.Value = "Excel"
End If

Thanks!
 
Hi Rosemary,

how about something like this:

with Me.Parent![Application].Form
if not .NewRecord then
.Recordset.AddNew
.Combo2 = "Excel"
end if
end with


Warm Regards,
Crystal
*
(: have an awesome day :)
*
MVP Access
Remote Programming and Training
strive4peace2006 at yahoo.com
*
 
Hi Crystal,

Thanks! Another question, please:

Here is what my code looks like (the example I provided before was
abbreviated). I just ran it, and, while I didn't get any error message,
nothing actually happened. That is, new records were not created and the
items "Website" and "Overnight Delivery" did not appear. (I tried the code
without the .Value and with the .Value).

What am I doing wrong?

Thanks again!
Rosemary

If InStr(1, Me.Combo92.Value, "FedEx Overnight Delivery") > 0 Then

With Me.Parent![sfrmApplication].Form
If Not .NewRecord Then
.Recordset.AddNew
.AppName.Value = "Website"
End If
End With

With Me.Parent![Finish].Form
If Not .NewRecord Then
.Recordset.AddNew
.Combo202.Value = "Overnight Delivery"
End If
End With

Me.Parent.Form.Title.Value = _
Me.Parent.Form.Title.Value & "FedEx Overnight Delivery"

Me.Parent.Form.DocNums.Value = _
Me.Parent.Form.DocNums.Value & "FedEx Overnight Delivery"

Me.Parent.Form.PageCount.Value = _
Me.Parent.Form.PageCount.Value & "0"

End If



strive4peace said:
Hi Rosemary,

how about something like this:

with Me.Parent![Application].Form
if not .NewRecord then
.Recordset.AddNew
.Combo2 = "Excel"
end if
end with


Warm Regards,
Crystal
*
(: have an awesome day :)
*
MVP Access
Remote Programming and Training
strive4peace2006 at yahoo.com
*


I have 2 Subforms on my Main form.

Each Subform contains a combo box with drop-down list. Their tables are on
the many side of the one-to-many relationship with the Main form.

When I make a selection on Subform 1, Subform 2 automatically populates with
a correlated item from its drop-down list.

PROBLEM: when I make a SECOND selection on Subform 1, the item that was
listed on Subform 2 gets replaced with the item correlating with the SECOND
selection.

How can I adjust my code so that the second item is ADDED to the list on
Subform 2 instead of replacing the first item?

A sample of the code to automatically populate Subform 2:

If InStr(1, Me.Combo1.Value, "Spreadsheet") > 0 Then
Me.Parent![Application].Form.Combo2.Value = "Excel"
End If

Thanks!
 
Hi Rosemary,

you're welcome ;)

when you use the Parent property, you do not need Form after it

change
Me.Parent.Form.Title.Value

to simply
Me.Parent.Title.Value

Warm Regards,
Crystal
*
(: have an awesome day :)
*
MVP Access
Remote Programming and Training
strive4peace2006 at yahoo.com
*


Hi Crystal,

Thanks! Another question, please:

Here is what my code looks like (the example I provided before was
abbreviated). I just ran it, and, while I didn't get any error message,
nothing actually happened. That is, new records were not created and the
items "Website" and "Overnight Delivery" did not appear. (I tried the code
without the .Value and with the .Value).

What am I doing wrong?

Thanks again!
Rosemary

If InStr(1, Me.Combo92.Value, "FedEx Overnight Delivery") > 0 Then

With Me.Parent![sfrmApplication].Form
If Not .NewRecord Then
.Recordset.AddNew
.AppName.Value = "Website"
End If
End With

With Me.Parent![Finish].Form
If Not .NewRecord Then
.Recordset.AddNew
.Combo202.Value = "Overnight Delivery"
End If
End With

Me.Parent.Form.Title.Value = _
Me.Parent.Form.Title.Value & "FedEx Overnight Delivery"

Me.Parent.Form.DocNums.Value = _
Me.Parent.Form.DocNums.Value & "FedEx Overnight Delivery"

Me.Parent.Form.PageCount.Value = _
Me.Parent.Form.PageCount.Value & "0"

End If



strive4peace said:
Hi Rosemary,

how about something like this:

with Me.Parent![Application].Form
if not .NewRecord then
.Recordset.AddNew
.Combo2 = "Excel"
end if
end with


Warm Regards,
Crystal
*
(: have an awesome day :)
*
MVP Access
Remote Programming and Training
strive4peace2006 at yahoo.com
*


I have 2 Subforms on my Main form.

Each Subform contains a combo box with drop-down list. Their tables are on
the many side of the one-to-many relationship with the Main form.

When I make a selection on Subform 1, Subform 2 automatically populates with
a correlated item from its drop-down list.

PROBLEM: when I make a SECOND selection on Subform 1, the item that was
listed on Subform 2 gets replaced with the item correlating with the SECOND
selection.

How can I adjust my code so that the second item is ADDED to the list on
Subform 2 instead of replacing the first item?

A sample of the code to automatically populate Subform 2:

If InStr(1, Me.Combo1.Value, "Spreadsheet") > 0 Then
Me.Parent![Application].Form.Combo2.Value = "Excel"
End If

Thanks!
 
Back
Top