Empty Records

R

Robert Painter

Good evening

I have a project almost finished and am making it error proof hopefully.

I have an Employee form where details are inputted for personal details and
then I have another form for inputting further data. I have a cmdAddSkills
button to go from frmEmployees to frmAddSkills. What happens is with the
following code:

Private Sub cmdAddSkill_Click()
On Error GoTo Err_cmdAddSkill_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "frmAddSkills"

stLinkCriteria = "[CustomisedID]=" & "'" & Me![CustomisedID] & "'"


DoCmd.Close acForm, "frmEmployees"
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_cmdAddSkill_Click:
Exit Sub

Err_cmdAddSkill_Click:
MsgBox Err.Description
Resume Exit_cmdAddSkill_Click

End Sub

What i need is to stop this happening if the record in frmEmployees remains
blank, based on CustomisedID. At present if the frmEmployees has been filled
in then the frmAddSkills record is there (by closing frmEmployees first),
but if the record in frmEmployees is an empty/new record then frmAddSkills
is just a clear page and the db bloats with empty records.



How can I do this please ??

Robert
 
R

Robert Painter

Wonderful just as i wanted.. thankyou very much
Robert


ruralguy via AccessMonster.com said:
Try:
Private Sub cmdAddSkill_Click()
On Error GoTo Err_cmdAddSkill_Click

If Not Me.NewRecord Then
Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "frmAddSkills"

stLinkCriteria = "[CustomisedID]=" & "'" & Me![CustomisedID] & "'"

DoCmd.Close acForm, "frmEmployees"
DoCmd.OpenForm stDocName, , , stLinkCriteria
End If
Exit_cmdAddSkill_Click:
Exit Sub

Err_cmdAddSkill_Click:
MsgBox Err.Description
Resume Exit_cmdAddSkill_Click

End Sub


Robert said:
Good evening

I have a project almost finished and am making it error proof hopefully.

I have an Employee form where details are inputted for personal details
and
then I have another form for inputting further data. I have a
cmdAddSkills
button to go from frmEmployees to frmAddSkills. What happens is with the
following code:

Private Sub cmdAddSkill_Click()
On Error GoTo Err_cmdAddSkill_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "frmAddSkills"

stLinkCriteria = "[CustomisedID]=" & "'" & Me![CustomisedID] & "'"

DoCmd.Close acForm, "frmEmployees"
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_cmdAddSkill_Click:
Exit Sub

Err_cmdAddSkill_Click:
MsgBox Err.Description
Resume Exit_cmdAddSkill_Click

End Sub

What i need is to stop this happening if the record in frmEmployees
remains
blank, based on CustomisedID. At present if the frmEmployees has been
filled
in then the frmAddSkills record is there (by closing frmEmployees first),
but if the record in frmEmployees is an empty/new record then frmAddSkills
is just a clear page and the db bloats with empty records.

How can I do this please ??

Robert

--
RuralGuy (RG for short) aka Allan Bunch MS Access MVP - acXP WinXP Pro
Please post back to this forum so all may benefit.

Message posted via AccessMonster.com
 
R

Robert Painter

Just been working thru and found that workaround doesnot do as i thought. I
have a button on the frmEmployees which i press when the record is filled in
but before it clears to another new form so it is not saved before i try to
leave so:

If Not Me.NewRecord Then

stops from leaving presumably because it is still a newrecord.

Robert


ruralguy via AccessMonster.com said:
Glad I could help.

Robert said:
Wonderful just as i wanted.. thankyou very much
Robert
Try:
Private Sub cmdAddSkill_Click()
[quoted text clipped - 64 lines]

--
RuralGuy (RG for short) aka Allan Bunch MS Access MVP - acXP WinXP Pro
Please post back to this forum so all may benefit.

Message posted via AccessMonster.com
 
R

Robert Painter

Hi
Yes it did that. I should be ok but what i was looking to do was allow the
move unless it was a new record. is there a way to automate this on the one
button. I did do it before and queried the:

stLinkCriteria = "[CustomisedID]=" & "'" & Me![CustomisedID] & "'"

next line queried before closing frmEmployees to save record but with:

If Me![CustomisedID] NULL Then
MsgBox "Blank Record Selected"

I never got the msgbox triggered.
Was i going the right way

Robert


ruralguy via AccessMonster.com said:
What I gave you should have *only* stopped the cmdAddSkill button from
working until you saved the record.

Robert said:
Just been working thru and found that workaround doesnot do as i thought.
I
have a button on the frmEmployees which i press when the record is filled
in
but before it clears to another new form so it is not saved before i try
to
leave so:

If Not Me.NewRecord Then

stops from leaving presumably because it is still a newrecord.

Robert
Glad I could help.
[quoted text clipped - 6 lines]

--
RuralGuy (RG for short) aka Allan Bunch MS Access MVP - acXP WinXP Pro
Please post back to this forum so all may benefit.

Message posted via AccessMonster.com
 
R

Robert Painter

Hi
Herewith code:

Private Sub cmdAddSkill_Click()
On Error GoTo Err_cmdAddSkill_Click

If Not Me.NewRecord Then
Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "formMain"

stLinkCriteria = "[CustomisedID]=" & "'" & Me![CustomisedID] & "'"
If Me![CustomisedID] = Null Then
MsgBox "Blank Record Selected"
exit_cmdAddSkill_Click:
Else

DoCmd.Close acForm, "frmEmployees"
DoCmd.OpenForm stDocName, , , stLinkCriteria
End If
End If

exit_cmdAddSkill_Click:
Exit Sub

Err_cmdAddSkill_Click:
MsgBox Err.Description
Resume exit_cmdAddSkill_Click

End Sub

Yes i am aware you can save before closing but i close this form and open
next one so only one form is open at a time, so no need to save.(Not sure
how that is done anyway)

Robert
ruralguy via AccessMonster.com said:
What you have will not work. Post all of the code starting with Private
Sub
so I can see what you are trying to accomplish. You do know that you do
not
have to close the form to save a record, right?

Robert said:
Hi
Yes it did that. I should be ok but what i was looking to do was allow
the
move unless it was a new record. is there a way to automate this on the
one
button. I did do it before and queried the:

stLinkCriteria = "[CustomisedID]=" & "'" & Me![CustomisedID] & "'"

next line queried before closing frmEmployees to save record but with:

If Me![CustomisedID] NULL Then
MsgBox "Blank Record Selected"

I never got the msgbox triggered.
Was i going the right way

Robert
What I gave you should have *only* stopped the cmdAddSkill button from
working until you saved the record.
[quoted text clipped - 18 lines]

--
RuralGuy (RG for short) aka Allan Bunch MS Access MVP - acXP WinXP Pro
Please post back to this forum so all may benefit.

Message posted via AccessMonster.com
 
R

Robert Painter

Wonderful. had to take out if not me.new record then and end if and now
works like a charm.
Thanks for your help. would have taken me ages to work it out by myself.

Robert

ruralguy via AccessMonster.com said:
Try this:
Private Sub cmdAddSkill_Click()
On Error GoTo Err_cmdAddSkill_Click

If Not Me.NewRecord Then
If Len(Me.CustomizedID & "") > 0 Then
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "formMain"
stLinkCriteria = "[CustomisedID]=" & "'" & Me![CustomisedID] & "'"
DoCmd.Close acForm, "frmEmployees"
DoCmd.OpenForm stDocName, , , stLinkCriteria
Else
MsgBox "Blank Record Selected"
End If
End If

exit_cmdAddSkill_Click:
Exit Sub

Err_cmdAddSkill_Click:
MsgBox Err.Description
Resume exit_cmdAddSkill_Click

End Sub


Robert said:
Hi
Herewith code:

Private Sub cmdAddSkill_Click()
On Error GoTo Err_cmdAddSkill_Click

If Not Me.NewRecord Then
Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "formMain"

stLinkCriteria = "[CustomisedID]=" & "'" & Me![CustomisedID] & "'"
If Me![CustomisedID] = Null Then
MsgBox "Blank Record Selected"
exit_cmdAddSkill_Click:
Else

DoCmd.Close acForm, "frmEmployees"
DoCmd.OpenForm stDocName, , , stLinkCriteria
End If
End If

exit_cmdAddSkill_Click:
Exit Sub

Err_cmdAddSkill_Click:
MsgBox Err.Description
Resume exit_cmdAddSkill_Click

End Sub

Yes i am aware you can save before closing but i close this form and open
next one so only one form is open at a time, so no need to save.(Not sure
how that is done anyway)

Robert
What you have will not work. Post all of the code starting with Private
Sub
[quoted text clipped - 26 lines]

--
RuralGuy (RG for short) aka Allan Bunch MS Access MVP - acXP WinXP Pro
Please post back to this forum so all may benefit.

Message posted via AccessMonster.com
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top