Code works in 2003 not 2007

T

Tim

I have this code in an inherited database that moves focus to the main form
and goes to a new record in the form.
****start code****
Private Sub cboObsType_LostFocus()
'If ObsType is blank, set focus on next record (move out of subform).
If Forms!frmDataEntry!subObsType!cboObsType <> "" Then
Else
Forms!frmDataEntry.SetFocus
Forms!frmDataEntry!txtKeypage.SetFocus
DoCmd.GoToRecord , , acNext
End If
End Sub
****end code****
The code seems to run without trouble when using Access 2003. If I open the
database in Access 2007, I can not open the form. More specifically when I
try to open the form from the switchboard, it opens briefly then closes. If
I comment the Else statment, I can open the form, but the behaivor is changed
(the subform will only allow one entry instead of multpile).

What do I change in the code so it my run in both versions of Access? We
have been slow in using just on version of Microsoft Office.

Thanks!
 
T

Tim

Thanks,

I tried the code and it set up the same behavior as the previous code with
Else commented out.

I can enter one record into the ObsType subform (subObsType.cboObsType), but
not multiple ObsType (it is a continous form). It is also the only field in
the subform.

The behavior I'm looking for is that hitting the tab key when in the
cboObsType field and it is null, I get moved to the main form and ready to
enter a new record.

Thanks,
Tim
 
T

Tim

That is correct, it is a subform (continuous) with one combo box per record.
Allow Addition is set to Yes for the form.

With the code you provided, I can enter one type of observation (say -
sighting). But if I heard (vocalization) and saw it, I am not able to enter
a second type of observation. After entering one type of observation and
hitting tab to enter another, I get moved to the main form and a new record.

Thanks,
Tim

ruralguy via AccessMonster.com said:
So you have a SubForm with one ComboBox showing in the Continuous form? Do
you have AllowAdditions set to YES on that form?
Thanks,

I tried the code and it set up the same behavior as the previous code with
Else commented out.

I can enter one record into the ObsType subform (subObsType.cboObsType), but
not multiple ObsType (it is a continous form). It is also the only field in
the subform.

The behavior I'm looking for is that hitting the tab key when in the
cboObsType field and it is null, I get moved to the main form and ready to
enter a new record.

Thanks,
Tim
Try:
Private Sub cboObsType_LostFocus()
[quoted text clipped - 28 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
 
T

Tim

It's not very exciting.

tblListObsType

It pulls directly from the table.

tim

ruralguy via AccessMonster.com said:
Can you post the SQL for the RowSource of that ComboBox?
That is correct, it is a subform (continuous) with one combo box per record.
Allow Addition is set to Yes for the form.

With the code you provided, I can enter one type of observation (say -
sighting). But if I heard (vocalization) and saw it, I am not able to enter
a second type of observation. After entering one type of observation and
hitting tab to enter another, I get moved to the main form and a new record.

Thanks,
Tim
So you have a SubForm with one ComboBox showing in the Continuous form? Do
you have AllowAdditions set to YES on that form?
[quoted text clipped - 20 lines]
 
T

Tim

The table has two fields ObsTypeCode and ObsTypeDesc. Both are text fields
with the code being the bound column. On the form this column is hidden and
you see the desciption. Niether field is a primary key.

tim

ruralguy via AccessMonster.com said:
Which is the bound column and what is returned in that field?
It's not very exciting.

tblListObsType

It pulls directly from the table.

tim
Can you post the SQL for the RowSource of that ComboBox?
[quoted text clipped - 14 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