SQL Statement, One More Time

User avatar
burrina
4StarLounger
Posts: 550
Joined: 30 Jul 2014, 23:58

SQL Statement, One More Time

Post by burrina »

I'm sure this is not correct but maybe you can see what I am trying to do.
Public Function CommandExecute(CommandNumber As Integer)
Dim strSQL As String
strSQL = Forms![frmAlarms]![txtFunctionName].RowSource = CommandExecute & Me.CommandNumber

User avatar
burrina
4StarLounger
Posts: 550
Joined: 30 Jul 2014, 23:58

Re: SQL Statement, One More Time

Post by burrina »

Or:

Public Function mySetSec(frmName As String)

Dim stLinkCriteria As String
stLinkCriteria = "[txtFunctionName] = " & "'" & txtFunctionName & "'"
frmName = frmAlarms
Select Case (TempVars!strFunctionName)
Case 1
DoCmd.Beep

User avatar
HansV
Administrator
Posts: 78475
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: SQL Statement, One More Time

Post by HansV »

I'm afraid that neither post makes sense to me, sorry. I have no idea what you are trying to do.
Best wishes,
Hans

User avatar
burrina
4StarLounger
Posts: 550
Joined: 30 Jul 2014, 23:58

Re: SQL Statement, One More Time

Post by burrina »

Ok. Thanks. I will continue to search for a way or an answer.
Again, Many Thanks.

User avatar
HansV
Administrator
Posts: 78475
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: SQL Statement, One More Time

Post by HansV »

It would be better if you explained what you want to do, instead of posting random bits of code...
Best wishes,
Hans

User avatar
burrina
4StarLounger
Posts: 550
Joined: 30 Jul 2014, 23:58

Re: SQL Statement, One More Time

Post by burrina »

Ok, simple: Is it possible to populate a combobox with values from a module?
I just need to know if it is or not. Then can proceed.

User avatar
HansV
Administrator
Posts: 78475
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: SQL Statement, One More Time

Post by HansV »

The generic answer is "yes", but I'd need detailed information for a more specific response.
Best wishes,
Hans

User avatar
burrina
4StarLounger
Posts: 550
Joined: 30 Jul 2014, 23:58

Re: SQL Statement, One More Time

Post by burrina »

One table: tblAlarms
AlarmID = PK
AlarmTime = Date/Time
FunctionName = Text

1 form; frmAlarms
4 fields:
txtAlarmTime
txtFunctionName
btnAddAlarm
lstAlarms which is a listbox that shows the added alarms.

1. set alarm time via txtAlarmTime
2. add text or vba command to run
3. click btnAddAlarm and run the code in the module if vba command, else display text on timed event
4. lstAlarms displays the alarms that have been added.

User avatar
HansV
Administrator
Posts: 78475
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: SQL Statement, One More Time

Post by HansV »

burrina wrote:
23 Dec 2020, 13:52
4. lstAlarms displays the alarms that have been added.
Should the list box display the alarm times, the function names, or both?
Best wishes,
Hans

User avatar
burrina
4StarLounger
Posts: 550
Joined: 30 Jul 2014, 23:58

Re: SQL Statement, One More Time

Post by burrina »

BOTH

User avatar
HansV
Administrator
Posts: 78475
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: SQL Statement, One More Time

Post by HansV »

OK. Make sure that the list box has the following properties:
Column Count: 3
Column Widths: 0
Row Source Type: Table/Query
Row Source: tblAlarms

txtAlarmTime and txtFunctionName should be unbound (their Control Source should be blank)

Create an On Click event procedure for btnAddAlarm:

Code: Select all

Private Sub btnAddalarm_Click()
    If IsNull(Me.txtAlarmTime) Then
        Me.txtAlarmTime.SetFocus
        MsgBox "Please enter the alarm time!", vbExclamation
        Exit Sub
    End If
    If IsNull(Me.txtFunctionName) Then
        Me.txtFunctionName.SetFocus
        MsgBox "Please enter the function name!", vbExclamation
        Exit Sub
    End If
    CurrentDb.Execute "INSERT INTO tblAlarms (AlarmTime, FunctionName) VALUES (#" & _
        Format(Me.txtAlarmTime, "mm/dd/yyyy hh:mm:ss AM/PM") & "#, '" & _
        Me.txtFunctionName & "')", dbFailOnError
    Me.lstAlarms.Requery
End Sub
Best wishes,
Hans

User avatar
burrina
4StarLounger
Posts: 550
Joined: 30 Jul 2014, 23:58

Re: SQL Statement, One More Time

Post by burrina »

Thank You Hans for your hard work.