By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
425,830 Members | 682 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 425,830 IT Pros & Developers. It's quick & easy.

Type mismatch when select by ComboBox

P: 5
I have two tables between them relationship, One of these tables is a Main-form and the other is Continuous Sub-form, The First Problem: when I put two Combo-box Wizard for find record from Main-form for Search, in query builder for these Combo-boxes appear two filed One of these filed FK and other filed with repeated data, and I make delete filed FK for unique value for other field, when go to form and select one of combo-box give me message "Type mismatch".

The second problem: from the same tables, Main-form and the other is Single Sub-form , i make Search by Text-box for sub-form, when Type Name give me "parameter value" and after press ok, the code go to First Record and Not the specified record.
thanks for help me.
by this code:

Expand|Select|Wrap|Line Numbers
  1. Private Sub ComSearch_Click()
  2. Dim KeyWord As String
  3. KeyWord = Me.txtSearch
  4. Me.Form.Filter = "Forms![AllNamesMain-1]![DetailsSub-1].Form![UserName] like '*" & KeyWord & "*'"
  5. ' DLookup("[UserName] ", "AllDetails", "UserNumber= '" & [UserName] & "' ")
  6. Me.Form.FilterOn = True
  7. Me.Form.FilterOn = False
  8. End Sub

Expand|Select|Wrap|Line Numbers
  1. Private Sub txtSearch_AfterUpdate()
  2. Call ComSearch_Click
  3. End Sub
The file in this link:
Mar 8 '18 #1
Share this Question
Share on Google+
7 Replies

Expert Mod 2.5K+
P: 3,205

Welcome to Bytes!

First, please use code tags when you post your code to this forum. I have edited your post so that it complies.

Second, in general, we are not going to download a database from a first-time user, for obvious security reasons.

Third, there appears to be a clear communication/language problem with your question. It is very difficult to decipher exactly what it is that you are asking--or what the specific problem is. However, I will try my best to look at what you've posted and make any comments/recommendations.

Concerning your first problem, it is unclear what the issue is, so I cannot comment.

In Line 4 of your first block of Code, the syntax you are using for a Filter is incorrect. Your Filter should simply be:

Expand|Select|Wrap|Line Numbers
  1. "[UserName] Like '*" & KeyWord & "*'"
In Lines 6 and 7, I am not sure why you are turning your Filter on and then immediately turning it off again. This could be why you are going to the first record and not the desired record(s).

Concerning your second procedure, I am not sure this is needed. You should put your code for ComSearch into the AfterUpdate procedure for the Text box OR keep it where it is, without a call to it from the AfterUpdate procedure. I can only see people wanting to search for something after they have updated the search field, but sometimes they want to click a button to search, rather than search automatically. Either way, it is not "wrong" to have it the way you have described.

As a side note, if you have two distinct problems/questions, we request you create two separate posts, so that each problem may be addressed individually. -Thanks from the Moderators!

Hope this hepps!
Mar 8 '18 #2

P: 5
Thank you for reply and comments, and I would like to clarify : I have two forms (Main-form and the other is Continuous Sub-form) , (Main-form and the other is Single Sub-form)
by this link some picture for problem:

Thank you again for help me.
Mar 8 '18 #3

Expert Mod 2.5K+
P: 3,205
I'm sorry but I can't access pictures on my work PC.

Also, pictures aren't going to help explain the problem. Concerning your first problem, A Type Mismatch error only occurs when you are trying to save data of one type into a variable or field that has an incompatible data type, for example saving a text string to an integer field.

However, you have not explained anything about your table structures, variables or forms that would give us any information on this. When is the error occuring? What line of your code is producing the error? This is the type of information we will need to help you.

Please provide additional, meaningful information relevant to your question so that we may more properly assist you.

Thank you.
Mar 8 '18 #4

P: 5
I edit the link picture
Mar 8 '18 #5

P: 5
I'm sure this link works ,You can download and see the file.
thank you for help me.
Mar 8 '18 #6

P: 5
can now see the picture by this link:
Mar 8 '18 #7

Expert Mod 2.5K+
P: 3,205
Please address the specific questions in Post #4. We can't solve a problem if we don't know the factors contributing to that problem.
Mar 8 '18 #8

Post your reply

Sign in to post your reply or Sign up for a free account.