copy record in subform

try this, and don't use Me.[cycle subform], i am already using it's Recordset so no need to use the Form.
Copy and Replace your code.

Code:
Private Sub Command1608_Click()
Dim bolWithBlank As Boolean
Dim bm As Variant
On Error GoTo new_Err

	With Me![cycle subform].Form.RecordsetClone
		If Not (.BOF And .EOF) Then
			.MoveFirst
			Do While Not .EOF
				If Len(Trim(!Cycle.Value & "")) = 0 Then
					bolWithBlank = True
					bm = .Bookmark
					Exit Do
				End If
				.MoveNext
			Loop
			If bolWithBlank then
				.Bookmark = bm
				.Edit
			Else
				.AddNew
			End If
			!Cycle = Me.No_of_Cycle.Value
			!date_ = Date
			.Update
		Else
				
			.AddNew
			!Cycle = Me.No_of_Cycle.Value
			!date_ = Date
			.Update
		End If
	End With
new_Err:
	Msgbox Err.Number & vbcrlf & Err.Description 
End Sub


the code work well but one issue why the linked ID of man form become blank
see picture
 

Attachments

  • form6.png
    form6.png
    26.1 KB · Views: 130
we will add it, what is the textbox name on the main form?

!Cycle = Me.No_Of_Cycle.Value
!Date = Date
!Record_ID = Me.??????.Value (texboxname in mainform)
 
we will add it, what is the textbox name on the main form?

!Cycle = Me.No_Of_Cycle.Value
!Date = Date
!Record_ID = Me.??????.Value (texboxname in mainform)

thanks alot

successfully solved

am rally appreciating your help .
 
ok, time for me to sleep
 
insert here (red text):
Code:
			!Cycle = Me.No_of_Cycle.Value
			!date_ = Date
			.Update
                        [COLOR="red"]Msgbox "Updated"[/COLOR]
		Else
				
			.AddNew
			!Cycle = Me.No_of_Cycle.Value
			!date_ = Date
			.Update
                        [COLOR="Red"]Msgbox "Updated"[/COLOR]
 
insert here (red text):
Code:
			!Cycle = Me.No_of_Cycle.Value
			!date_ = Date
			.Update
                        [COLOR="red"]Msgbox "Updated"[/COLOR]
		Else
				
			.AddNew
			!Cycle = Me.No_of_Cycle.Value
			!date_ = Date
			.Update
                        [COLOR="Red"]Msgbox "Updated"[/COLOR]

thanks alot its OK now.
i appreciate your help
 
youre welcome!
 

Users who are viewing this thread

Back
Top Bottom