If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Display Modes |
#21
|
|||
|
|||
Duplicating reocords from main form and subform
Think i fixed that, now i'm getting this error: Microsoft Access can't find
the field "I" referred to in your expression John W. Vinson wrote: In the statement - WHERE TripID = " & Me.TripID & ";" Method or Data Member Not Found That suggests that there is in fact nothing on the current Form (Me.) named TripID. -- Message posted via AccessMonster.com http://www.accessmonster.com/Uwe/For...forms/200904/1 |
#22
|
|||
|
|||
Duplicating reocords from main form and subform
On Tue, 21 Apr 2009 19:49:40 GMT, "rarerock via AccessMonster.com"
u51057@uwe wrote: Think i fixed that, now i'm getting this error: Microsoft Access can't find the field "I" referred to in your expression In that case you're trying to write to, or read from, a field named "I" and that there is no such field. Check your code and be sure your variables contain what you think they do. -- John W. Vinson [MVP] |
#23
|
|||
|
|||
Duplicating reocords from main form and subform
heres the code now. No errors, but the newly created record is blank??
Private Sub Duplicate_Click() On Error GoTo Err_Handler 'Purpose: Duplicate the main form record and related records in the subform. Dim strSql As String 'SQL statement. Dim lngID As Long 'Primary key value of the new record. 'Save and edits first If Me.Dirty Then Me.Dirty = False End If 'Make sure there is a record to duplicate. If Me.NewRecord Then MsgBox "Select the record to duplicate." Else 'Duplicate the main record: add to form's clone. With Me.recordsetclone .AddNew !FNAME = Me.FNAME !LNAME = Me.LNAME !PHONE = Me.PHONE !DCODE = Me.DCODE !TYDATE = Me.TYDATE !TPDATE = Me.TPDATE !PLOCATION = Me.PLOCATION !PTIME = Me.PTIME !ATIME = Me.ATIME !DLOCATION = Me.DLOCATION !RLOCATION = Me.RLOCATION !LTIME = Me.LTIME !RTIME = Me.RTIME !STAFF = Me.STAFF !COMMENTS = Me.COMMENTS 'etc for other fields. .Update 'Save the primary key value, to use as the foreign key for the related records. .Bookmark = .LastModified lngID = !TRIPN 'Duplicate the related records: append query. If Me.[Rider].Form.recordsetclone.RecordCount 0 Then strSql = "INSERT INTO [Triders](TRIPN,NameID,TypeID)" & _ "SELECT " & lngID & " As NewID,NameID,TypeID " & _ "FROM [triders] WHERE (TRIPN = " & Me.TRIPN & ");" DBEngine(0)(0).Execute strSql, dbFailOnError Else MsgBox "Main record duplicated, but there were no related records." End If 'Display the new duplicate. Me.Bookmark = .LastModified End With End If Exit_Handler: Exit Sub Err_Handler: MsgBox "Error " & Err.Number & " - " & Err.Description, , "Duplicate_Click" Resume Exit_Handler End Sub John W. Vinson wrote: Think i fixed that, now i'm getting this error: Microsoft Access can't find the field "I" referred to in your expression In that case you're trying to write to, or read from, a field named "I" and that there is no such field. Check your code and be sure your variables contain what you think they do. -- Message posted via AccessMonster.com http://www.accessmonster.com/Uwe/For...forms/200904/1 |
#24
|
|||
|
|||
Duplicating reocords from main form and subform
Not sure if you saw my last post. I'm still playing with this code, when i
duplicate the record it is blank, i even removed the sql statement to see if that was the problem, only the PK and the FK number advances in either case? Any idea why? John W. Vinson wrote: Think i fixed that, now i'm getting this error: Microsoft Access can't find the field "I" referred to in your expression In that case you're trying to write to, or read from, a field named "I" and that there is no such field. Check your code and be sure your variables contain what you think they do. -- Message posted via http://www.accessmonster.com |
Thread Tools | |
Display Modes | |
|
|