473,325 Members | 2,442 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,325 software developers and data experts.

Multi-List boxes and navigation

I'm developing an A2K adp that contains doctor info and the months
they are not available for teaching. A doctor can be unavailable for
some months for one year and other months for another year. I want
the user to enter the year then use a multi-select list box to choose
the months not available, then go to a fresh screen, enter another
year and choose the months not available for that year, and so on. In
the table, there is one record per year/month per doctor.

I've got the form set up and I can enter one year and the months but
can't figure out how to navigate to a fresh screen and enter the next
year. Maybe using a multi-select listbox isn't the way to go??? Any
ideas? Thanks.
Nov 12 '05 #1
2 1987
Ellen Manning wrote:
I'm developing an A2K adp that contains doctor info and the months
they are not available for teaching. A doctor can be unavailable for
some months for one year and other months for another year. I want
the user to enter the year then use a multi-select list box to choose
the months not available, then go to a fresh screen, enter another
year and choose the months not available for that year, and so on. In
the table, there is one record per year/month per doctor.

I've got the form set up and I can enter one year and the months but
can't figure out how to navigate to a fresh screen and enter the next
year. Maybe using a multi-select listbox isn't the way to go??? Any
ideas? Thanks.


Why not? I am not sure how many columns you have. You can see in my
example I use 0 as the first column is the column I want to use (the
column property starts at zero so if you have 5 columns, it is 0-4).

I would have a button to update the months to igrnore in the table.
Let's say your table has the fields called DoctorID, YearAvail, and the
months are Yes/No for availability and are called Jan...Dec. On the
form you have a DoctorID field you are working on, the YearAvail. The
listbox name is called ListMon. The listbox has 1 column; Jan...Dec

Sub CommandSelectAvailability_Click

'no need to process if doctorid or year is empty.
If IsNull(Me.DoctorID) Or IsNull(Me.YearAvail) Then Exit Sub

Dim var As Variant
Dim strMon As STring
Dim intFor As Integer
Dim intYear As Integer
Dim rst As DAO.Recordset

Set rst = Currentdb.openrecordset("Availability",dbopendynas et)

'find the doctor record for the year
rst.findfirst "DoctorID = " & Me.DoctorID & " And " _
"YearAvail = " & Me.YearAvail

'if found, edit the availablity record else add one.
If not rst.nomatch then
rst.Edit
Else
'if not found, create a new record
rst.AddNew
rst!DoctorID = Me.DoctorID
rst!Year = Me.YearAvail
Endif

'if editing, clear out any settings first
intYear = Year(Date())
For intFor = 1 to 12
'assign to variable Jan-Dec
strMon = Format(DateSerial(intYear,intFor,1),"mmm")

'now set that month to false
rst(strMon) = False
Next

'loop through all selected months and set to Available = True
For Each var In Me.ListMon.ItemsSelected
'assign the month to true
strMon = Me.ListMon.Column(0, var)
rst(strMon) = True

'now de-select that month
Me.ListMon.Selected(var) = False
Next

'commit the changes and close recordset
rst.Update
rst.close
set rst = Nothing

'clear out the Year
Me.YearAvail = Null

'keep the same doctor. go to the doctor field
Me.DoctorID.SetFocus
End Sub

I would probably have a routine that once a doctorID and Year is
entered to see if the record exists and set the Selected property to
true so you can see what has already been selected. I've provided
enough code for you to see how that can be done. Instead of looping
through the list of ItemsSeleted, you would do a loop using
For I = 0 TO Me.ListMOn.ListCount -1
...set month to true or false for existing records
Next
Nov 12 '05 #2
Ellen Manning wrote:
I'm developing an A2K adp that contains doctor info and the months
they are not available for teaching. A doctor can be unavailable for
some months for one year and other months for another year. I want
the user to enter the year then use a multi-select list box to choose
the months not available, then go to a fresh screen, enter another
year and choose the months not available for that year, and so on. In
the table, there is one record per year/month per doctor.

I've got the form set up and I can enter one year and the months but
can't figure out how to navigate to a fresh screen and enter the next
year. Maybe using a multi-select listbox isn't the way to go??? Any
ideas? Thanks.


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

The list box method of selecting months is OK, but you have to know that
all the selected values (records) will have to be written to the table
one-at-a-time. You can use a stored procedure (SP) & VBA code. Example
of the SP:

CREATE PROCEDURE usp_AddDoctorUnavailable
- -- If the DoctorNotAvailable table has more than these columns
- -- you will have to adjust the SP & the VBA code to insert those
- -- columns.

@DoctorID INTEGER ,
@Month DATETIME -- Format YYYYMM01

AS

INSERT INTO DoctorNotAvailable (DoctorID, Month)
VALUES (@DoctorID, @Month)

====

There should be a CommandButton on the form that saves the data to the
table "DoctorNotAvailable" (use the real table's name). E.g.
(untested):

Private Sub cmdSave_Click()
' In:
' Me!lstMonths The months to save
' Me!txtDoctorID The doctor's ID
' Me!txtYear The year the months are in
'

Dim cn As New ADODB.Connection
Dim strSQL As String
Dim strExec As String
Dim varRow as Variant

On Error GoTo err_

cn.Connection = CurrentProject.Connection
cn.Open

strSQL = "EXEC usp_AddDoctorUnavailable " & Me!txtDoctorID & ", "

' Assumes the list box's bound column returns the month number,
' and that txtYear holds a 4-digit year.
For Each varRow In Me!lstMonths.ItemsSelected
With Me!lstMonths
' Format the date to "YYYYMM01" & attach to EXEC statement.
' Note: single quotes have to surround the date value.
strExec = strSQL & " '" & Me!txtYear & _
Format(.ItemData(varRow),"00") & "01'"
cn.Execute strExec,,adCmdText
End With
Next varRow

' If reached here - success!
' Clear the selected values from the list box
' to show the user that the info was saved.
' Or show a MsgBox saying saved.
With Me!lstMonths
For Each varRow In .ItemsSelected
.Selected(varRow) = False
Next varRow
End With

exit_:
cn.Close
Set cn = Nothing
Exit Sub

err_:
' You may want to check for duplicates & just Resume Next
' instead of running the MsgBox.
MsgBox "An error occurred while saving the Doctor's " & _
"Unavailable months" & vbcr & vbcr & "Error: " & _
err.Description, vbCritical
Resume exit_

End Sub

--
MGFoster:::mgf00 <at> earthlink <decimal-point> net
Oakland, CA (USA)

-----BEGIN PGP SIGNATURE-----
Version: PGP for Personal Privacy 5.0
Charset: noconv

iQA/AwUBQH2udYechKqOuFEgEQK7ygCgkHfBI/HrAT4myW0qLQ50aeXwuOgAoLeY
rE92g44aXedjv2946IxhwxIY
=kzJ9
-----END PGP SIGNATURE-----

Nov 12 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

37
by: ajikoe | last post by:
Hello, Is anyone has experiance in running python code to run multi thread parallel in multi processor. Is it possible ? Can python manage which cpu shoud do every thread? Sincerely Yours,...
4
by: Frank Jona | last post by:
Intellisense with C# and a multi-file assembly is not working. With VB.NET it is working. Is there a fix availible? We're using VisualStudio 2003 Regards Frank
12
by: * ProteanThread * | last post by:
but depends upon the clique: ...
0
by: frankenberry | last post by:
I have multi-page tiff files. I need to extract individual frames from the multi-page tiffs and save them as single-page tiffs. 95% of the time I receive multi-page tiffs containing 1 or more black...
6
by: cody | last post by:
What are multi file assemblies good for? What are the advantages of using multiple assemblies (A.DLL+B.DLL) vs. a single multi file assembly (A.DLL+A.NETMODULE)?
4
by: mimmo | last post by:
Hi! I should convert the accented letters of a string in the correspondent letters not accented. But when I compile with -Wall it give me: warning: multi-character character constant Do the...
5
by: Shane Story | last post by:
I can seem to get the dimensions of a frame in a multiframe tiff. After selecting activeframe, the Width/Height is still really much larger than the page's actual dimensions. When I split a...
5
by: bobwansink | last post by:
Hi, I'm relatively new to programming and I would like to create a C++ multi user program. It's for a project for school. This means I will have to write a paper about the theory too. Does anyone...
0
by: Sabri.Pllana | last post by:
We apologize if you receive multiple copies of this call for papers. *********************************************************************** 2008 International Workshop on Multi-Core Computing...
1
by: mknoll217 | last post by:
I am recieving this error from my code: The multi-part identifier "PAR.UniqueID" could not be bound. The multi-part identifier "Salary.UniqueID" could not be bound. The multi-part identifier...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.