I am looking to update a bank table using a combo box with 2 details: Bank Name and Sort Code.
I currently have a concatenated combo box, but am I able to add new information such as BankName : BankSortCode on update with a separator such as " : " to identify the 2 separate identities, and write this information back to the Bank table?
Any help on this would be greatly appreciated.
Many thanks
Tim
Just remove the Bank.BankID column and you should be OK.
cheers,
12 2790
Tim,
You can refer to multiple fields within a combo box named cbMyComboBox using cbMyComboBox.Column(0) [first field], cbMyComboBox.Column(1) [second field], etc.
Hi Steve
Thanks for this, but not 100% sure how to implement this. At present, I am just trying to put a separator in, as I do not want 2 columns in my combo box, just the one.
At present, my code is -
Private Sub cboBank_NotInList(NewBank As String, NewSortCode As String, strSeparator As Variant, Response As Integer)
-
Dim mbxResponse As VbMsgBoxResult
-
Dim strSQL As String
-
-
-
mbxResponse = MsgBox("Are you sure you want to add " & NewBank & strSeparator & NewSortCode & _
-
"as a new Bank?", vbQuestion + vbYesNo)
-
-
If mbxResponse = vbYes Then
-
-
strSQL = "INSERT INTO Bank([BankName]) " & _
-
"VALUES('" & NewBank & "');"
-
strSQL = "INSERT INTO Bank([BankSortCode]) " & _
-
"VALUES('" & NewSortCode & "');"
-
Call DoCmd.SetWarnings(False)
-
Call DoCmd.RunSQL(strSQL)
-
Call DoCmd.RunSQL(strSQL1)
-
Call MsgBox( _
-
"The new bank information has been added to the database.", vbInformation)
-
-
Response = acDataErrAdded
-
-
Else
-
Response = acDataErrDisplay
-
-
End If
-
-
End Sub
-
I am new to this as well, as you will probably have guessed, so any help is much appreciated!
Thanks a lot
Tim
Tim, I'm getting lost on what you are trying to accomplish. If I can help I'll need a bigger picture. What does your Bank table look like (fields in it) and what are you trying to allow the user to do?
Steve
This does not make sense.
You have created two seperate SQL Insert queries but the 2nd one overwrites the first.
You then reference strSQL1 later but there is no query for it.
If your second SQL Insert query is supposed to be strSQL1 instead of strSQL it will still not make sense because you are then trying to insert 2 seperate records with different field values and ignore other fields.
Like Steve says you need to give us a better picture of what you are trying to accomplish.
cheers,
Thank you for coming back to me about this, and sorry for the delay in replying.
As an overview, I am trying to produce a combo box where, if the required value is not present, I can type it in.
At present, I have a combo box that has Bank Name and Bank Sort Code in a single concatenated field. This contains something like the following:-
HSBC 400000
NatWest 600000
RBS 160000
I would like my users to be able to add records by typing the following:-
HSBC;400500
which would then put HSBC into the Bank Name field in my table Bank, and would put 400500 into the Bank Sort Code field in the table Bank, and would then update the combo box to show this value.
I am trying not to open a form to do this, but to use a separator to split the 2 elements of the information that is input into the 2 different fields in the table.
I need to have the sortcode separate from the Bank Name, but it is necessary to have both pieces of information in there. I am happy to hear or any other ways that I can achieve this, and once again, thank you for your assistance.
Cheers
Tim
If I understand you correctly you can try code something like so in the afterupdate event of your combo box: -
' check if the entry in the combo box has a ";" character
-
If InStr(Me.YourComboBox.Value, ";") Then
-
Dim aStrInsert
-
Dim strSQL As String
-
'split the combo box value into 2 values using the ";" as the seperator
-
aStrInsert = Split(Me.YourComboBox.Value, ";", 2)
-
' insert a new record with the 2 split values from the combo box
-
strSQL = "INSERT INTO tblBank (BankName, BankSort) VALUES "
-
strSQL = strSQL & "('" & aStrInsert(0) & "'," & aStrInsert(1) & ");"
-
DoCmd.RunSQL strSQL
-
Me.YourComboBox.Requery
-
End If
-
This assumes that no ";" characters are allowed in either your BankName or BankOrder fields.
Your Combo box "Limit to List" property is set to "No"
Assumes you have an autonumber Primary key in the Bank table.
Assumes the end user put the bank name and bank order in the correct order in the combo box ie: Bank Name first, bank order second. (you really should do some kind of error checking for this)
Change your control names, field names, table names accordingly.
cheers,
Many thanks for this, looks really good. Only problem that I have is that my combo box is bound to my primary key value, which is hidden, and as such I cannot change the Limit to List property to "No", unless I unhide the primary key (which is an autonumber), and then the combo box doesn't give me the values that I want displayed!
I think I may look at getting a form to load to update the information, unless you have any other suggestions? Thanks for all of your help, it is really appreciated.
Kind regards
Tim
What do you mean it does not give you what you want. All you need to do is create a proper query for the Row Source of the combo box.
If you give more details I may be able to create it for you.
But I will say that the way you want to do it with just the combo box is not the ideal way to go. Normally you would create a proper form with proper value checking and such to ensure data entegrity.
cheers,
Thanks Mshmyob
I think that I will look at the proper form, to ensure that the data I capture is correct.
For your info, the Query that I have in the Row Source at present is:-
SELECT Bank.BankID, Bank.BankName, Bank.BankSortCode FROM Bank ORDER BY Bank.BankName;
Thanks for all your help
Tim
Just remove the Bank.BankID column and you should be OK.
cheers,
Thanks mshmyob
All sorted and really appreciate your help.
Cheers
Tim
You're welcome. Good luck with the rest of your project.
cheers,
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Prakash Wadhwani |
last post by:
In a small Contacts Database, I have 6 Boolean(Yes/No) Fields so that
6 individuals in the company can maintain their own private mailing
list.
The names of the fields are as follows:
Commander...
|
by: David Lao |
last post by:
Hi All,
I need a way to extract Data value from the Outlook form
when the new mails arrive. The data fields are provided.
Thanks.
David
|
by: MLH |
last post by:
I have a number of reports that are essentially black 'n
white prepared forms (picture an IRS form 1040). The
data fields are overlaid onto the report fields in the
correct positions and I would...
|
by: Java script Dude |
last post by:
Hi,
I basically need to write a script that will make calls to a DLL and
parse the return result for API calls that consist of several data
fields in the input and output parameters.
Is...
|
by: pconrad |
last post by:
I've got a syslog server posting to MS SQL. It works great as far as posting all the data. However, it puts all the useful information into one big text field called message.
How can I parse that...
|
by: ASMJ |
last post by:
Hi,
I have a web page with some data fields contained in the panel and a
grid view below it. The data fields are not placed in the position in
which they are designed when I run the appln. After a...
|
by: wavbuser |
last post by:
Is there a simple way, without setting up a module, to get certain data fields to carry over to a new record as well in MS Access 2003. I've tried alot of modifications to the "default value" but...
|
by: sijugeo |
last post by:
Hi,
I Have a MS word template field which have certain data fields. I want to populate the data fields using the data retrived from SQL db. How can I do this?
Thanks in advance
Siju george
|
by: boss1 |
last post by:
hi everyone,
i m having a problem with my php update code.
i have 7 text fields in a webpage.
i have written a code for updating multiple fields in database and it's working properly.but the...
|
by: datsandgirl |
last post by:
First of all, please let me apologize in advance for my lack of technical knowledge and proper terminology skills when it comes to databases. I have never taken any classes, but have only felt my...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
| |