Automatically retreiving information

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,

I'm making client profiles. Each profile is based on a abbreviation of the
name and location (5 letters). The details of the company like its code, name
and location is being retrieved from a different form to what I'm currently
using. What I need to do is that when I type in the code to enter a record,
it automatically produces the company name and location rather than the user
choosing down the drop down box or when I enter the company name and
location, the abbreviation code automatically comes up. Any help would be
great.

Thanks,
Saima
 
If set up correctly, the user doesn't have to "choose down a drop down". The
best way to do this is to use a combo box with Auto Expand set to Yes. This
way, the user can type in the value just like they would in a text box. It
also gives them visual feedback on whether they are typing in the value
correctly. It is also a lot less coding on your part. Here is some example
code I threw together (Pardon the lack of naming convention) that will allow
the user to select which field they want to search on by using a command
button. In this example, if the current search is by Activity, clicking the
button switches to search on description and visa versa. The combo is not
bound to a field, so it doesn't matter which way they search, when the record
is found, all the controls are loaded.

Private Sub Combo0_AfterUpdate()
Dim rst As DAO.Recordset
Dim strCriteria As String

If Me.Combo0.BoundColumn = 1 Then
strCriteria = "[Activity] = '"
Else
strCriteria = "[DESCRIPTION] = '"
End If
strCriteria = strCriteria & Me.Combo0.Column(0) & "'"
Set rst = Me.RecordsetClone
rst.FindFirst strCriteria
If Not rst.NoMatch Then
Me.Bookmark = rst.Bookmark
End If
Set rst = Nothing
End Sub

Private Sub Command6_Click()
Dim strAct As String
Dim strDesc As String

strAct = "SELECT CISAttributeTable.ACTIVITY,
CISAttributeTable.DESCRIPTION FROM CISAttributeTable;"
strDesc = "SELECT CISAttributeTable.DESCRIPTION,
CISAttributeTable.ACTIVITY FROM CISAttributeTable;"
If Me.Combo0.BoundColumn = 1 Then
Me.Combo0.BoundColumn = 2
Me.Combo0.RowSource = strDesc
Me.Combo0.ColumnWidths = "2.5"";1.1"""
Else
Me.Combo0.BoundColumn = 1
Me.Combo0.RowSource = strAct
Me.Combo0.ColumnWidths = "1.1"";2.5"""
End If
End Sub
 
Thank you for your help, it worked out.

Saima

Klatuu said:
If set up correctly, the user doesn't have to "choose down a drop down". The
best way to do this is to use a combo box with Auto Expand set to Yes. This
way, the user can type in the value just like they would in a text box. It
also gives them visual feedback on whether they are typing in the value
correctly. It is also a lot less coding on your part. Here is some example
code I threw together (Pardon the lack of naming convention) that will allow
the user to select which field they want to search on by using a command
button. In this example, if the current search is by Activity, clicking the
button switches to search on description and visa versa. The combo is not
bound to a field, so it doesn't matter which way they search, when the record
is found, all the controls are loaded.

Private Sub Combo0_AfterUpdate()
Dim rst As DAO.Recordset
Dim strCriteria As String

If Me.Combo0.BoundColumn = 1 Then
strCriteria = "[Activity] = '"
Else
strCriteria = "[DESCRIPTION] = '"
End If
strCriteria = strCriteria & Me.Combo0.Column(0) & "'"
Set rst = Me.RecordsetClone
rst.FindFirst strCriteria
If Not rst.NoMatch Then
Me.Bookmark = rst.Bookmark
End If
Set rst = Nothing
End Sub

Private Sub Command6_Click()
Dim strAct As String
Dim strDesc As String

strAct = "SELECT CISAttributeTable.ACTIVITY,
CISAttributeTable.DESCRIPTION FROM CISAttributeTable;"
strDesc = "SELECT CISAttributeTable.DESCRIPTION,
CISAttributeTable.ACTIVITY FROM CISAttributeTable;"
If Me.Combo0.BoundColumn = 1 Then
Me.Combo0.BoundColumn = 2
Me.Combo0.RowSource = strDesc
Me.Combo0.ColumnWidths = "2.5"";1.1"""
Else
Me.Combo0.BoundColumn = 1
Me.Combo0.RowSource = strAct
Me.Combo0.ColumnWidths = "1.1"";2.5"""
End If
End Sub


Saima said:
Hi,

I'm making client profiles. Each profile is based on a abbreviation of the
name and location (5 letters). The details of the company like its code, name
and location is being retrieved from a different form to what I'm currently
using. What I need to do is that when I type in the code to enter a record,
it automatically produces the company name and location rather than the user
choosing down the drop down box or when I enter the company name and
location, the abbreviation code automatically comes up. Any help would be
great.

Thanks,
Saima
 

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

Back
Top