label caption

divaam

Registered User.
Local time
Tomorrow, 04:12
Joined
Apr 30, 2019
Messages
18
hi, i need your help
i have a form 'search' to search single data that I have in some tables.
the form contain 3 combobox; 'combotable' to choose table, 'comboyears' to choose field year in table, and 'combofield' to choose the fields in the table.
when i click command button i want to display the fill in the field that i choose based on the year using label

search = comboyears.Value
tabel = Me.combotable.Value
Set rs = CurrentDb.OpenRecordset(tabel, dbOpenSnapshot, dbReadOnly)
rs.FindFirst "[" & Me.cmbIndi.Value & "] is null and [Tahun]='" & Me.cmbTahun.Value & "'"

If rs.NoMatch Then
LblData.Caption = [rs(" & Me.cmbIndi.Value & ") is not null And (Year) = search].Value

in the last syntax sill error, i dont know what is wrong.
may somebody can help me
thank youu
 
Just a guess but try taking out the square brackets.
 
Just want to display the data of the field that i choose based on year

LblData.Caption = rs(" & Me.cmbIndi.Value & ").Value WHERE (Tahun) = search

but syntax WHERE cannot use in here (error)
i'm newbie in access, any idea?
 
Just want to display the data of the field that i choose based on year

LblData.Caption = rs(" & Me.cmbIndi.Value & ").Value WHERE (Tahun) = search

but syntax WHERE cannot use in here (error)
i'm newbie in access, any idea?

Hi. Ah yes, can’t use WHERE there. What do you get if you simply take it out?
 
Hi. Ah yes, can’t use WHERE there. What do you get if you simply take it out?

I want to display the data of the field that I choose based on year
for example

Year A B C
2008 1 3 4
2009 2 3 2
2010 1 2 3

I have combobox 'comboyear' to choose the year
and combobox 'combofield' to choose betwee A,B, or C
if I choose year 2009 and field B then I click command button, so the label wil display "3"
like this. I hope you can help me, thank yoouuu
 
Post your database, zip it because you haven't post 10 post yet.
 
I want to display the data of the field that I choose based on year
for example

Year A B C
2008 1 3 4
2009 2 3 2
2010 1 2 3

I have combobox 'comboyear' to choose the year
and combobox 'combofield' to choose betwee A,B, or C
if I choose year 2009 and field B then I click command button, so the label wil display "3"
like this. I hope you can help me, thank yoouuu
Have you tried something like?
Code:
DLookup([combofield],"TableName","[Year]=" & [comboyear])
 
Have you tried something like?
Code:
DLookup([combofield],"TableName","[Year]=" & [comboyear])

still cannot fix this :banghead:
would you see the database above? thanks
 
still cannot fix this :banghead:
would you see the database above? thanks
Hi. This is far from a complete solution but should be enough to get you started. Let us know if you have any questions.
 

Attachments

Hi. This is far from a complete solution but should be enough to get you started. Let us know if you have any questions.

Hey thank you so much for your help, its work.
How if I want to change the button to delete button?
 
Hey thank you so much for your help, its work.
How if I want to change the button to delete button?

Depends on what you want to happen when the user clicks it. Do you want to delete the whole row or just empty the cell?
 
just to empty the cell
So, that would be something like:
Code:
Dim strSQL As String


strSQL = "UPDATE " & Me.ComboForTable & " SET " & Me.ComboForField & "=Null WHERE [Year]=" & Me.ComboForYear


CurrentDb.Execute strSQL, dbFailOnError
Hope it helps...
 
So, that would be something like:
Code:
Dim strSQL As String


strSQL = "UPDATE " & Me.ComboForTable & " SET " & Me.ComboForField & "=Null WHERE [Year]=" & Me.ComboForYear


CurrentDb.Execute strSQL, dbFailOnError
Hope it helps...

thank you so much for your helping.
actually i dont know what is difference function of brackets " "; ' '; & &; [ ]; etc
so i'm confused and always have an error syntax:D
 
So, that would be something like:
Code:
Dim strSQL As String


strSQL = "UPDATE " & Me.ComboForTable & " SET " & Me.ComboForField & "=Null WHERE [Year]=" & Me.ComboForYear


CurrentDb.Execute strSQL, dbFailOnError
Hope it helps...

helo
I still have a run time error whe I develop this syntax

Me.LblData.Caption = DLookup(Me.cmbIndi, Me.cmbPub, "[Tahun]=" & Me.cmbTahun)

the access said run-time error '3075'
syntax error (missing operator) in query expression 'Total Hotel'

where 'Total Hotel' is the value of cmbIndi
can you help me what's wrong?
 
Firstly stop asking the same questions in two different threads please.:(

You said in this thread here that it was solved?

DLookup *returns* a value, most times by using some criteria.?
You cannot use a field element with spaces unless you surround the field in square brackets []

So if the contents of Me.cmbIndi can have spaces, enclose it in square brackets.

Try
Code:
Me.LblData.Caption = DLookup("[" & Me.cmbIndi & "]", Me.cmbPub, "[Tahun]=" & Me.cmbTahun)

HTH
 

Users who are viewing this thread

Back
Top Bottom