Change Form to No Save

B

Bob

Is it possible to change this Code so if "cbOwnerID" is empty it will not
save!
VBA Code:
Private Sub cmdClose_Click()
If Me.OpenArgs = "ActiveHorses" Then
Me.Requery
Forms!frmActiveHorses.Visible = True
Forms!frmActiveHorses!cbHorseName.Requery
End If
subSetValues
DoCmd.Close acForm, Me.Name
End Sub


Thanks in advance.........Bob Vance
 
N

Nikos Yannacopoulos

Bob,

Try something along the lines of:

Private Sub cmdClose_Click()
Dim iSave As Integer
If Me.OpenArgs = "ActiveHorses" Then
Me.Requery
Forms!frmActiveHorses.Visible = True
Forms!frmActiveHorses!cbHorseName.Requery
End If
subSetValues
If IsNull(Me.cbOwnerID) Then
iSave = 2
Else
iSave = 1
End If
DoCmd.Close acForm, Me.Name, iSave
End Sub

HTH,
Nikos
 
N

Nikos Yannacopoulos

What does the compiler error say? Any chance the combo name is misspelt?
Is your code exactly as below? If not please post your exact code.

Nikos
 
B

Bob

Code is the same, I tried dropping the cb but still got the same error
Compile error
Methord or Data member not found
and cbOwnerID is highlighted
if i Form Design the second time I get subHorseDetails
Thanks Bob
 
N

Nikos Yannacopoulos

Bob,

This says Me.cbOwnerID is not a valid object reference. There are two
possible reasons for this, either (a) the combo is not actually called
cbOwnerID (check the Name property in form design), or (b) the command
button and the combo are not both on the same form (any chance one is on
the main form and the othe on a subform?). Please check and confirm.

Nikos
 

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

Similar Threads


Top