copy record in subform (1 Viewer)

theinviter

Registered User.
Local time
Yesterday, 20:08
Joined
Aug 14, 2014
Messages
240
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: 93

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 11:08
Joined
May 7, 2009
Messages
19,238
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)
 

theinviter

Registered User.
Local time
Yesterday, 20:08
Joined
Aug 14, 2014
Messages
240
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 .
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 11:08
Joined
May 7, 2009
Messages
19,238
ok, time for me to sleep
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 11:08
Joined
May 7, 2009
Messages
19,238
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]
 

theinviter

Registered User.
Local time
Yesterday, 20:08
Joined
Aug 14, 2014
Messages
240
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
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 11:08
Joined
May 7, 2009
Messages
19,238
youre welcome!
 

Users who are viewing this thread

Top Bottom