Unbound form and combobox for Country and Salution Selection

silentwolf

Active member
Local time
, 20:23
Joined
Jun 12, 2009
Messages
655
Hi guys,

just wondering how to go about using an unbound form and a Country Combobox to select or choose the approbiate country for the record.

I use an unbound form and fill Data with Recordset.

However there are Country and Salution linked to that table and I like to use comboboxes to select Salution or the approbiate Country in the form.

How can or should that be done?

Thanks for advice

Albert
 
Try searching for Cascading Comboboxes, which is what it sounds like you want.
 
Hi the DBguy,

no sorry that is not what I am looking for :(
But thanks anyway )
Will try to work it out...
 
search.PNG
 
Hi guys sorry if it was not clear,

normally I use as suggested access to handle forms and it works perfect.
However I was wondering how to create it with recordset.

Here is a code snippet what I have in Form1

Code:
Dim db As Database
Dim rst As Recordset

Private Sub Form_Load()
    Set db = CurrentDb
    Set rst = db.OpenRecordset("qryTenants", dbOpenDynaset, dbSeeChanges)
    
    Do Until rst.EOF
        Me.lstTenant.AddItem rst!SurName
        rst.MoveNext
    Loop
    
    rst.MoveFirst
    RefreshData
End Sub

Private Sub RefreshData()
    If Not rst.BOF And Not rst.EOF Then
        Me.txtTenantID = rst!TenantID
        Me.txtSalutionID = rst!SalutionID
        Me.txtFirstName = rst!FirstName
        Me.txtSurName = rst!SurName
        Me.txtTenantName = rst!TenantName
        Me.txtDOB = rst!DOB
        Me.txtAddress = rst!Address
        Me.txtTown = rst!Town
        Me.txtPostcode = rst!Postcode
        Me.txtCountryID = rst!CountryID
    End If
End Sub

Private Sub btnFirstRecord_Click()
    rst.MoveFirst
    RefreshData
End Sub

Private Sub btnPreviousRecord_Click()
    If Not rst.BOF Then
        rst.MovePrevious
        RefreshData
    End If
End Sub

Private Sub btnNextRecord_Click()
    If Not rst.EOF Then
        rst.MoveNext
        RefreshData
    End If
End Sub

Private Sub btnLastRecord_Click()
    rst.MoveLast
    RefreshData
End Sub

This code example I used is from Steve Bishop:


Are you asking how to select values from a combo with code? The answer is - you must hard-code the selection since you have no user to pick from a list. AND, that means that if the combo shows text but stores an ID, then you must populate the combo with the ID value and NOT the text value.

Yes that is my question :)

Just for my understanding how would you need to work with recordest if there are more tables involved as tblCountry to pick a Country within the form from a combobox. And likewise with Salution.

I understand that this is more work but was just wondering how to do it not for any billing purpose ;-)

Just for my own usage and to understand it better.

And why would you use recordsets in the first place as it is more work?

What are the benifits to do so?

There are tutorials and so forth for using recordest in unbound forms but as far as I found tutorials there where always simple tables used with no relationships.

Hope this is more clear now many thanks
 
Hi Pat,

thank you for your explaination and your link to your databases!
I will look into it and if there are questions I will let you know!

Many thanks!

Cheers
Albert
 

Users who are viewing this thread

Back
Top Bottom