need help with MS Access

skim milk

Diamond Member
Apr 8, 2003
5,784
1
0
I have a form that displays whatever is in the tables.

I want a search box that will search in a specific column and bring up that entry in the form

As an example, a database consists of a list of projects. I want to search by using the project number in a form

I need the VB code to get this to work.. I've searched all over the place.
 

KLin

Lifer
Feb 29, 2000
30,169
540
126
1. Create combo box in form header
2. make rowsource the list of projects (SELECT Project from tblProject Order by Project)
3. in the afterupdate event of the newly created combo box add the following code
__________

Me.RecordsetClone.FindFirst "[ProjectFieldName] = '" & [ComboBoxName] & "'"
Me.Bookmark = Me.RecordsetClone.Bookmark
[ComboBoxName] = Null
___________

[ComboBoxName] is whatever name you give the combobox in the other tab for it's properties.
[ProjectFieldName] is whatever the actual field name is of the project field within the table.

4. Nextel, done.
 

skim milk

Diamond Member
Apr 8, 2003
5,784
1
0
Originally posted by: KLin
1. Create combo box in form header
2. make rowsource the list of projects (SELECT Project from tblProject Order by Project)
3. in the afterupdate event of the newly created combo box add the following code
__________

Me.RecordsetClone.FindFirst "[ProjectFieldName] = '" & [ComboBoxName] & "'"
Me.Bookmark = Me.RecordsetClone.Bookmark
[ComboBoxName] = Null
___________

[ComboBoxName] is whatever name you give the combobox in the other tab for it's properties.
[ProjectFieldName] is whatever the actual field name is of the project field within the table.

4. Nextel, done.


sweet, thanks a lot KLin.

I don't know much Access...
I tried it but it didn't work for it. Maybe I'm doing it wrong

Here's the code in my After Update:
Me.RecordsetClone.FindFirst "Project# = '" & Combo58 & "'"
Me.Bookmark = Me.RecordsetClone.Bookmark
Combo58 = Null

I get a syntax error in time expression

and in the combo box where the drop down arrow is.. it displays just the ID 1,2,3,4,5,etc. when I click on it.
I want to be able to input a number into the box and click a "search" button or pressing enter would bring up the project
if you provide a step by step in more detail, it will be really helpful.
I'll give this a shot tomorrow.. I'm leaving now. Thanks again

 

KLin

Lifer
Feb 29, 2000
30,169
540
126
Originally posted by: fritolays
Originally posted by: KLin
1. Create combo box in form header
2. make rowsource the list of projects (SELECT Project from tblProject Order by Project)
3. in the afterupdate event of the newly created combo box add the following code
__________

Me.RecordsetClone.FindFirst "[ProjectFieldName] = '" & [ComboBoxName] & "'"
Me.Bookmark = Me.RecordsetClone.Bookmark
[ComboBoxName] = Null
___________

[ComboBoxName] is whatever name you give the combobox in the other tab for it's properties.
[ProjectFieldName] is whatever the actual field name is of the project field within the table.

4. Nextel, done.


sweet, thanks a lot KLin.

I don't know much Access...
I tried it but it didn't work for it. Maybe I'm doing it wrong

Here's the code in my After Update:
Me.RecordsetClone.FindFirst "Project# = '" & Combo58 & "'"
Me.Bookmark = Me.RecordsetClone.Bookmark
Combo58 = Null

I get a syntax error in time expression

and in the combo box where the drop down arrow is.. it displays just the ID 1,2,3,4,5,etc. when I click on it.
I want to be able to input a number into the box and click a "search" button or pressing enter would bring up the project
if you provide a step by step in more detail, it will be really helpful.
I'll give this a shot tomorrow.. I'm leaving now. Thanks again

That's the project ID field. You can make it show the description, but be bound to the Project ID if you want. You need to enclose project# in square brackets (ie [Project#]).

1. Change the rowsource to "SELECT [Project#], ProjectDesc from tblProject Order by
ProjectDesc"
2. Bring up the properties of combo58
3. under the format tab, change the column count to 2
4. under column widths, change it to 0;.5" (or however long it needs to be to show the full desc.
5. This should show the project name/desc but it will still use the project# to find the row. Make sure project# is part of the form recordsource too.