Originally posted by Rabbit
How can I autofil the City and State fields by entering a Zip?
Collapse
X
-
-
I was wondering if you could help me out again. I am basically trying to do the same thing again so I took the code you have written for me and adjusted it. I must not have done it correctly though because it keeps giving me an error. I couldn't find anything else like it on the sight so I thought Id ask.Originally posted by RabbitNot a problem, good luck.
This is how I changed the code. I have a table that has the Asset and Cusip on it with a name of asset/cusip and on the form I have Asset/Tr-Acct number and Cusip number. Unfortunatly I cannot change the labels on the form to make them less wordy due to certian security measures placed on the Table. If it matters not every asset on the table has a cusip.Code:Private Sub CUSIP_NUMBER_AfterUpdate() Me.[ASSET/TR-ACCT_NUMBER] = DLookup("[ASSET]", "[ASSET/CUSIP]", "[CUSIP] = " & Me.[CUSIP_NUMBER]) End SubComment
-
It returns;Originally posted by RabbitGeneral syntax of DLookup is:
Is it returning anything at all? What is it doing wrong? Is CusID a number or text?Code:DLookup("[Field Name]", "[Table Name]", "Where Statement")
data type mismatch in criteria expression.
Which means I have labeled something incorrectly right?
The CusID is text because there are sometimes letters in it so as far as I know I cannot change the field to a number.Comment
-
Ok I did that and now it gives me this error;Originally posted by RabbitYou have to surround text with quotes. No quotes means it's a number or a field.Code:Private Sub CUSIP_NUMBER_AfterUpdate() Me.[ASSET/TR-ACCT_NUMBER] = DLookup("[ASSET]", "[ASSET/CUSIP]", "[CUSIP] = '" & Me.[CUSIP_NUMBER] & "'") End Sub
Microsoft Office Access can't find the field 'I' referred to in your expression.Comment
-
I'm sorry if I'm not doing something correctly. I would greatly appreciate at least some kind of response since it has been two days since my last post and I have not been able to figure it out on my own. Thank you.Originally posted by Crayola465Ok I did that and now it gives me this error;
Microsoft Office Access can't find the field 'I' referred to in your expression.Comment
-
Ok, thank you for responding. I seem to be hitting a wall here. The zip code part works great so I would think this would work just as well.Originally posted by RabbitI have no idea why it's doing that. As long as you are referring to everything correctly, it should work.
Let's see if any of the experts can shed a light on this.Comment
-
Does anyone know why this code is not working?Originally posted by Crayola465Ok, thank you for responding. I seem to be hitting a wall here. The zip code part works great so I would think this would work just as well.
Private Sub CUSIP_NUMBER_Af terUpdate()
Me.[ASSET/TR-ACCT_NUMBER] = DLookup("[ASSET]", "[ASSET/CUSIP]", "[CUSIP] = '" & Me.[CUSIP_NUMBER] & "'")
End SubComment
-
1) Make sure CUSIP is a text field in the table, when it's a number use:Originally posted by Crayola465Does anyone know why this code is not working?
Private Sub CUSIP_NUMBER_Af terUpdate()
Me.[ASSET/TR-ACCT_NUMBER] = DLookup("[ASSET]", "[ASSET/CUSIP]", "[CUSIP] = '" & Me.[CUSIP_NUMBER] & "'")
End Sub
Me.[ASSET/TR-ACCT_NUMBER] = DLookup("[ASSET]", "[ASSET/CUSIP]", "[CUSIP] = " & Me.[CUSIP_NUMBER] )
2) Add:
Me.Refresh
Before the End sub to make sure the result will show.
Nic;o)Comment
-
CUSIP is text.Originally posted by nico50381) Make sure CUSIP is a text field in the table, when it's a number use:
Me.[ASSET/TR-ACCT_NUMBER] = DLookup("[ASSET]", "[ASSET/CUSIP]", "[CUSIP] = " & Me.[CUSIP_NUMBER] )
2) Add:
Me.Refresh
Before the End sub to make sure the result will show.
Nic;o)
Looking over the older posts brought something to my attention. In one post you said it was CUSID but it's CUSIP everywhere else, is everything spelled correctly?Comment
-
I tried the Me.Refresh and that does nothing. I also double checked the spelling on everything and made sure everything was set to text. It still comes up with the same error; Microsoft Office can't find the field "I" referred to in your expression. It must have something to do with the single quotes but I don't know what to do.Originally posted by RabbitCUSIP is text.
Looking over the older posts brought something to my attention. In one post you said it was CUSID but it's CUSIP everywhere else, is everything spelled correctly?Comment
Comment