Texbox retrieve data depends on combo box

G

Guest

Hi,Im beginner of MS Access.I've dificulties in creating a form.
I have tables which are:
tblRoom(IDRoom,NoRoom,IDBlock,IDType,IDPrice,Occupied,Notes)
tblBlock(IDBlock,NameBlock)
tblType(IDType,Type)
tblPrice(IDPrice,Price)

The form contain 1st combo that list all the NameBlock from tblBlock and
2nd combo that list all the NoRoom from tblRoom depends on 1st combo

My question is how can I make one textbox in the same form show the Type
from tblType that depend on 2nd combo and the texbox can't be editable.

Thanks for spent times reading my Question.
 
G

Guest

Add the data you want to display to the Combo RowSource

Select Field1,Field2 From TableName

If it's includes more then one table, then add the second table and add the
nes field.
Make sure that the Column Count property in the combo includes the number of
columns.
If you want to hide this column you can use the ColumnWidth property.
2 cm;0 cm

In the text box you can refer to this column in the combo by writing in the
ControlSource
=[ComboName].Column(1)

*****
Note: the column number start with 0, so the second column will be 1
*****

By writing that in the ControlSource of the text box, the user wont be able
to edit it.

===========================
The second option will be, to use DlookUp in the ControlSource of the Text Box

= DlookUp("[FieldName]","[TableNAme]","[FieldNameForSerch]=" & [ComboName])

If the field you are searching by is string then use
= DlookUp("[FieldName]","[TableNAme]","[FieldNameForSerch]='" & [ComboName]
& "'")
 
G

Guest

Hi again..I tried to make dlookup but it doesn't work..it just become #Name?.

This is my 1st combo's Row Source:
SELECT tblBlock.IDBlock, tblBlock.Nama_Block FROM tblBlock;

my 2nd combo's Row Source:
SELECT tblBilik.IDBilik, tblBilik.NoBilik, tblBilik.IDBlock,
tblBilik.IDJenis, tblBilik.IDHarga FROM tblBilik WHERE
(((tblBilik.IDBlock)=Forms![Pendaftaran Masuk]!cboNamaBlok)) ORDER BY
tblBilik.NoBilik;

Then I tried to make the textbox Control Source:
Dlookup ("[Jenis]","[tblJenis]","[IDJenis]='"& [cboNoBilik] & "'")

my Dlookup is wrong?I confused because it need the data from 2 tables..

Ofer Cohen said:
Add the data you want to display to the Combo RowSource

Select Field1,Field2 From TableName

If it's includes more then one table, then add the second table and add the
nes field.
Make sure that the Column Count property in the combo includes the number of
columns.
If you want to hide this column you can use the ColumnWidth property.
2 cm;0 cm

In the text box you can refer to this column in the combo by writing in the
ControlSource
=[ComboName].Column(1)

*****
Note: the column number start with 0, so the second column will be 1
*****

By writing that in the ControlSource of the text box, the user wont be able
to edit it.

===========================
The second option will be, to use DlookUp in the ControlSource of the Text Box

= DlookUp("[FieldName]","[TableNAme]","[FieldNameForSerch]=" & [ComboName])

If the field you are searching by is string then use
= DlookUp("[FieldName]","[TableNAme]","[FieldNameForSerch]='" & [ComboName]
& "'")

--
Good Luck
BS"D


yanz said:
Hi,Im beginner of MS Access.I've dificulties in creating a form.
I have tables which are:
tblRoom(IDRoom,NoRoom,IDBlock,IDType,IDPrice,Occupied,Notes)
tblBlock(IDBlock,NameBlock)
tblType(IDType,Type)
tblPrice(IDPrice,Price)

The form contain 1st combo that list all the NameBlock from tblBlock and
2nd combo that list all the NoRoom from tblRoom depends on 1st combo

My question is how can I make one textbox in the same form show the Type
from tblType that depend on 2nd combo and the texbox can't be editable.

Thanks for spent times reading my Question.
 
G

Guest

Hi,

Do you have equal sign before the DlookUp, without it you'll get NAME

=Dlookup ("[Jenis]","[tblJenis]","[IDJenis]='"& [cboNoBilik] & "'")

--
Good Luck
BS"D


yanz said:
Hi again..I tried to make dlookup but it doesn't work..it just become #Name?.

This is my 1st combo's Row Source:
SELECT tblBlock.IDBlock, tblBlock.Nama_Block FROM tblBlock;

my 2nd combo's Row Source:
SELECT tblBilik.IDBilik, tblBilik.NoBilik, tblBilik.IDBlock,
tblBilik.IDJenis, tblBilik.IDHarga FROM tblBilik WHERE
(((tblBilik.IDBlock)=Forms![Pendaftaran Masuk]!cboNamaBlok)) ORDER BY
tblBilik.NoBilik;

Then I tried to make the textbox Control Source:
Dlookup ("[Jenis]","[tblJenis]","[IDJenis]='"& [cboNoBilik] & "'")

my Dlookup is wrong?I confused because it need the data from 2 tables..

Ofer Cohen said:
Add the data you want to display to the Combo RowSource

Select Field1,Field2 From TableName

If it's includes more then one table, then add the second table and add the
nes field.
Make sure that the Column Count property in the combo includes the number of
columns.
If you want to hide this column you can use the ColumnWidth property.
2 cm;0 cm

In the text box you can refer to this column in the combo by writing in the
ControlSource
=[ComboName].Column(1)

*****
Note: the column number start with 0, so the second column will be 1
*****

By writing that in the ControlSource of the text box, the user wont be able
to edit it.

===========================
The second option will be, to use DlookUp in the ControlSource of the Text Box

= DlookUp("[FieldName]","[TableNAme]","[FieldNameForSerch]=" & [ComboName])

If the field you are searching by is string then use
= DlookUp("[FieldName]","[TableNAme]","[FieldNameForSerch]='" & [ComboName]
& "'")

--
Good Luck
BS"D


yanz said:
Hi,Im beginner of MS Access.I've dificulties in creating a form.
I have tables which are:
tblRoom(IDRoom,NoRoom,IDBlock,IDType,IDPrice,Occupied,Notes)
tblBlock(IDBlock,NameBlock)
tblType(IDType,Type)
tblPrice(IDPrice,Price)

The form contain 1st combo that list all the NameBlock from tblBlock and
2nd combo that list all the NoRoom from tblRoom depends on 1st combo

My question is how can I make one textbox in the same form show the Type
from tblType that depend on 2nd combo and the texbox can't be editable.

Thanks for spent times reading my Question.
 
G

Guest

Thanks it work but contain no data. I think it should be my mistake when
called the data. I still blur how to relate those 2 tables with dlookup. I
wanna make Jenis from tblJenis appear which is IDJenis same with IDJenis from
tblBilik but tblBilik. Can you check my DLookup, have I forgot something? Or
if there is any other suggestion, it is my pleasure to hear. I'll try to
learn it. Thanks again.

Ofer Cohen said:
Hi,

Do you have equal sign before the DlookUp, without it you'll get NAME

=Dlookup ("[Jenis]","[tblJenis]","[IDJenis]='"& [cboNoBilik] & "'")

--
Good Luck
BS"D


yanz said:
Hi again..I tried to make dlookup but it doesn't work..it just become #Name?.

This is my 1st combo's Row Source:
SELECT tblBlock.IDBlock, tblBlock.Nama_Block FROM tblBlock;

my 2nd combo's Row Source:
SELECT tblBilik.IDBilik, tblBilik.NoBilik, tblBilik.IDBlock,
tblBilik.IDJenis, tblBilik.IDHarga FROM tblBilik WHERE
(((tblBilik.IDBlock)=Forms![Pendaftaran Masuk]!cboNamaBlok)) ORDER BY
tblBilik.NoBilik;

Then I tried to make the textbox Control Source:
Dlookup ("[Jenis]","[tblJenis]","[IDJenis]='"& [cboNoBilik] & "'")

my Dlookup is wrong?I confused because it need the data from 2 tables..

Ofer Cohen said:
Add the data you want to display to the Combo RowSource

Select Field1,Field2 From TableName

If it's includes more then one table, then add the second table and add the
nes field.
Make sure that the Column Count property in the combo includes the number of
columns.
If you want to hide this column you can use the ColumnWidth property.
2 cm;0 cm

In the text box you can refer to this column in the combo by writing in the
ControlSource
=[ComboName].Column(1)

*****
Note: the column number start with 0, so the second column will be 1
*****

By writing that in the ControlSource of the text box, the user wont be able
to edit it.

===========================
The second option will be, to use DlookUp in the ControlSource of the Text Box

= DlookUp("[FieldName]","[TableNAme]","[FieldNameForSerch]=" & [ComboName])

If the field you are searching by is string then use
= DlookUp("[FieldName]","[TableNAme]","[FieldNameForSerch]='" & [ComboName]
& "'")

--
Good Luck
BS"D


:

Hi,Im beginner of MS Access.I've dificulties in creating a form.
I have tables which are:
tblRoom(IDRoom,NoRoom,IDBlock,IDType,IDPrice,Occupied,Notes)
tblBlock(IDBlock,NameBlock)
tblType(IDType,Type)
tblPrice(IDPrice,Price)

The form contain 1st combo that list all the NameBlock from tblBlock and
2nd combo that list all the NoRoom from tblRoom depends on 1st combo

My question is how can I make one textbox in the same form show the Type
from tblType that depend on 2nd combo and the texbox can't be editable.

Thanks for spent times reading my Question.
 
G

Guest

Thank you a lot with your posts..it's working greatly..
I do not set the Column Count and Column Width at the combo before..
what I should do if I wanna make those textboxs can be edit? I can't use
DLookUp right?
However,thanks again..I've learn a thing today :D


Ofer Cohen said:
Hi,

Do you have equal sign before the DlookUp, without it you'll get NAME

=Dlookup ("[Jenis]","[tblJenis]","[IDJenis]='"& [cboNoBilik] & "'")

--
Good Luck
BS"D


yanz said:
Hi again..I tried to make dlookup but it doesn't work..it just become #Name?.

This is my 1st combo's Row Source:
SELECT tblBlock.IDBlock, tblBlock.Nama_Block FROM tblBlock;

my 2nd combo's Row Source:
SELECT tblBilik.IDBilik, tblBilik.NoBilik, tblBilik.IDBlock,
tblBilik.IDJenis, tblBilik.IDHarga FROM tblBilik WHERE
(((tblBilik.IDBlock)=Forms![Pendaftaran Masuk]!cboNamaBlok)) ORDER BY
tblBilik.NoBilik;

Then I tried to make the textbox Control Source:
Dlookup ("[Jenis]","[tblJenis]","[IDJenis]='"& [cboNoBilik] & "'")

my Dlookup is wrong?I confused because it need the data from 2 tables..

Ofer Cohen said:
Add the data you want to display to the Combo RowSource

Select Field1,Field2 From TableName

If it's includes more then one table, then add the second table and add the
nes field.
Make sure that the Column Count property in the combo includes the number of
columns.
If you want to hide this column you can use the ColumnWidth property.
2 cm;0 cm

In the text box you can refer to this column in the combo by writing in the
ControlSource
=[ComboName].Column(1)

*****
Note: the column number start with 0, so the second column will be 1
*****

By writing that in the ControlSource of the text box, the user wont be able
to edit it.

===========================
The second option will be, to use DlookUp in the ControlSource of the Text Box

= DlookUp("[FieldName]","[TableNAme]","[FieldNameForSerch]=" & [ComboName])

If the field you are searching by is string then use
= DlookUp("[FieldName]","[TableNAme]","[FieldNameForSerch]='" & [ComboName]
& "'")

--
Good Luck
BS"D


:

Hi,Im beginner of MS Access.I've dificulties in creating a form.
I have tables which are:
tblRoom(IDRoom,NoRoom,IDBlock,IDType,IDPrice,Occupied,Notes)
tblBlock(IDBlock,NameBlock)
tblType(IDType,Type)
tblPrice(IDPrice,Price)

The form contain 1st combo that list all the NameBlock from tblBlock and
2nd combo that list all the NoRoom from tblRoom depends on 1st combo

My question is how can I make one textbox in the same form show the Type
from tblType that depend on 2nd combo and the texbox can't be editable.

Thanks for spent times reading my Question.
 

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