Okay Brains, here's one that I am sick of searching for.
I dreamt this up, but it won't work - obviously, maybe one of you can tweak it for me. This code below tells me that there is no Current Record ... well duh! I want it to add one if the record doesn't exist, and if it already does - I want it to treat it like a normal form open. Maybe I'm going about it all wrong, but I'm hoping that this code is somehere on the path to the COrrect Code.. FYI: 'assignmentnumber' is the txtbox in my form..
Private Sub Form_Open(Cancel As Integer)
Dim DB As Database
Dim RS As Recordset
Set DB = CurrentDb()
Set RS = DB.OpenRecordset("tblpropertysurvey"
With RS
RS.Move (Me.CurrentRecord) 'My problem is around here
If RS[assignmentnumber] = assignmentnumber Then
Exit Sub
Else
.AddNew
RS![assignmentnumber] = assignmentnumber
.Update
End If
End With
Set DB = Nothing
Set RS = Nothing
End Sub
My prob is that if the record doens't exist then there isn't a record to move to - so I get an error. ANy clues?
-Josh ------------------
-JPeters
Got a helpful tip for Access Users? Check out and contribute to 'How to Keep Your Databases from becoming Overwhelming!'
thread181-293590
jpeters@guidemail.com
------------------
I dreamt this up, but it won't work - obviously, maybe one of you can tweak it for me. This code below tells me that there is no Current Record ... well duh! I want it to add one if the record doesn't exist, and if it already does - I want it to treat it like a normal form open. Maybe I'm going about it all wrong, but I'm hoping that this code is somehere on the path to the COrrect Code.. FYI: 'assignmentnumber' is the txtbox in my form..
Private Sub Form_Open(Cancel As Integer)
Dim DB As Database
Dim RS As Recordset
Set DB = CurrentDb()
Set RS = DB.OpenRecordset("tblpropertysurvey"
With RS
RS.Move (Me.CurrentRecord) 'My problem is around here
If RS[assignmentnumber] = assignmentnumber Then
Exit Sub
Else
.AddNew
RS![assignmentnumber] = assignmentnumber
.Update
End If
End With
Set DB = Nothing
Set RS = Nothing
End Sub
My prob is that if the record doens't exist then there isn't a record to move to - so I get an error. ANy clues?
-Josh ------------------
-JPeters
Got a helpful tip for Access Users? Check out and contribute to 'How to Keep Your Databases from becoming Overwhelming!'
thread181-293590
jpeters@guidemail.com
------------------