Field is not getting value in Access 2007

D

Deanna

Hi,
I need some help with the code below. It is the same working code in Access
97 and 2003, but it is not working in Access 2007. There is no error. The
problem is txtbox1 is not getting the value in Me!lstDat.Column(2). When I
debug, the Me!lstDat.Column(2) has the correct value, but txtbox1 is null.

Any suggestion will be helpful! We are converting to Access 2007 in 2 weeks.

Thanks!

Deanna

Private Sub lstDat_Click()

On Error GoTo lstDat_Click_Err_Handler

DoCmd.Hourglass True

Forms!frmAddDepartments!lbl1.Caption = "Category"
Forms!frmAddDepartments!lbl1.Visible = True
Forms!frmAddDepartments!txtBox1.Visible = True
Forms!frmAddDepartments!txtBox1.SetFocus
'Forms!frmAddDepartments!txtBox1 = Me!lstDat.Column(5)
Forms!frmAddDepartments!txtBox1 = Me!lstDat.Column(2)
Forms!frmAddDepartments!txtSubDepartment = Me!lstDat.Column(1)
Me.txtBox1.Value = Me!lstDat.Column(2)
Forms!frmAddDepartments!cmdAddM.Enabled = True

DoCmd.Hourglass False

Exit Sub

lstDat_Click_Err_Handler:
DoCmd.Hourglass False
MsgBox "An error has occurred in lstDat_Click section of
frmAddDepartments. " & Err.Description
Exit Sub
End Sub
 
D

dymondjack

Just a shot in the dark, but try Me!lstDat.Column(2).Value

I've never used '07 but I don't see anything a quick glance that might cause
it.

--
Jack Leach
www.tristatemachine.com

- "Success is the ability to go from one failure to another with no loss of
enthusiasm." - Sir Winston Churchill
 
D

Deanna

After many trial and error, I got it to work. I found the SetFocus couldn't
be set on the Forms!frmAddDepartments!txtBox1
Instead, I set it on lstdat. However, I don't why the reason though.

I also found at one point this code didn't work:
Me.txtBox1 = Me.lstDat.Column(2)

The I change it to this as you suggested:

Me!txtBox1 = Me.lstDat.Column(2)

Later, I found Me.txtBox1 = Me.lstDat.Column(2) working again.

Strange!

Thanks for all your help!

Deanna

AccessVandal via AccessMonster.com said:
Try other ways of using Dots and Bangs like

Me.txtBox1 = Me.lstDat.Column(2)
or
Me!txtBox1 = Me!lstDat.Column(2)
or
Me!txtBox1.Value = Me!lstDat.Column(2)

It is a known fact that this problem is in A2007. Sometimes it's intermittent,
sometimes not and sometime the problem is also form view mode to design mode.

And are they the same data type?
I am sorry. It doesn't work either. Any other suggestions?
Just a shot in the dark, but try Me!lstDat.Column(2).Value
[quoted text clipped - 39 lines]
Exit Sub
End Sub
 

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